
obj/user/icode:     file format elf32-i386


Disassembly of section .text:

00800020 <_start>:
// starts us running when we are initially loaded into a new environment.
.text
.globl _start
_start:
	// See if we were started with arguments on the stack
	cmpl $USTACKTOP, %esp
  800020:	81 fc 00 e0 bf ee    	cmp    $0xeebfe000,%esp
	jne args_exist
  800026:	75 04                	jne    80002c <args_exist>

	// If not, push dummy argc/argv arguments.
	// This happens when we are loaded by the kernel,
	// because the kernel does not know about passing arguments.
	pushl $0
  800028:	6a 00                	push   $0x0
	pushl $0
  80002a:	6a 00                	push   $0x0

0080002c <args_exist>:

args_exist:
	call libmain
  80002c:	e8 2b 01 00 00       	call   80015c <libmain>
1:	jmp 1b
  800031:	eb fe                	jmp    800031 <args_exist+0x5>
	...

00800034 <umain>:
#include <inc/lib.h>

void
umain(void)
{
  800034:	55                   	push   %ebp
  800035:	89 e5                	mov    %esp,%ebp
  800037:	56                   	push   %esi
  800038:	53                   	push   %ebx
  800039:	81 ec 30 02 00 00    	sub    $0x230,%esp
	int fd, n, r;
	char buf[512+1];

	binaryname = "icode";
  80003f:	c7 05 00 70 80 00 40 	movl   $0x802f40,0x807000
  800046:	2f 80 00 

	cprintf("icode startup\n");
  800049:	c7 04 24 46 2f 80 00 	movl   $0x802f46,(%esp)
  800050:	e8 38 02 00 00       	call   80028d <cprintf>

	cprintf("icode: open /motd\n");
  800055:	c7 04 24 55 2f 80 00 	movl   $0x802f55,(%esp)
  80005c:	e8 2c 02 00 00       	call   80028d <cprintf>
	if ((fd = open("/motd", O_RDONLY)) < 0)
  800061:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  800068:	00 
  800069:	c7 04 24 68 2f 80 00 	movl   $0x802f68,(%esp)
  800070:	e8 f7 19 00 00       	call   801a6c <open>
  800075:	89 c6                	mov    %eax,%esi
  800077:	85 c0                	test   %eax,%eax
  800079:	79 20                	jns    80009b <umain+0x67>
		panic("icode: open /motd: %e", fd);
  80007b:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80007f:	c7 44 24 08 6e 2f 80 	movl   $0x802f6e,0x8(%esp)
  800086:	00 
  800087:	c7 44 24 04 0f 00 00 	movl   $0xf,0x4(%esp)
  80008e:	00 
  80008f:	c7 04 24 84 2f 80 00 	movl   $0x802f84,(%esp)
  800096:	e8 2d 01 00 00       	call   8001c8 <_panic>

	cprintf("icode: read /motd\n");
  80009b:	c7 04 24 91 2f 80 00 	movl   $0x802f91,(%esp)
  8000a2:	e8 e6 01 00 00       	call   80028d <cprintf>
	while ((n = read(fd, buf, sizeof buf-1)) > 0)
  8000a7:	8d 9d f7 fd ff ff    	lea    -0x209(%ebp),%ebx
  8000ad:	eb 0c                	jmp    8000bb <umain+0x87>
		sys_cputs(buf, n);
  8000af:	89 44 24 04          	mov    %eax,0x4(%esp)
  8000b3:	89 1c 24             	mov    %ebx,(%esp)
  8000b6:	e8 95 0c 00 00       	call   800d50 <sys_cputs>
	cprintf("icode: open /motd\n");
	if ((fd = open("/motd", O_RDONLY)) < 0)
		panic("icode: open /motd: %e", fd);

	cprintf("icode: read /motd\n");
	while ((n = read(fd, buf, sizeof buf-1)) > 0)
  8000bb:	c7 44 24 08 00 02 00 	movl   $0x200,0x8(%esp)
  8000c2:	00 
  8000c3:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8000c7:	89 34 24             	mov    %esi,(%esp)
  8000ca:	e8 14 14 00 00       	call   8014e3 <read>
  8000cf:	85 c0                	test   %eax,%eax
  8000d1:	7f dc                	jg     8000af <umain+0x7b>
		sys_cputs(buf, n);

	cprintf("icode: close /motd\n");
  8000d3:	c7 04 24 a4 2f 80 00 	movl   $0x802fa4,(%esp)
  8000da:	e8 ae 01 00 00       	call   80028d <cprintf>
	close(fd);
  8000df:	89 34 24             	mov    %esi,(%esp)
  8000e2:	e8 b5 15 00 00       	call   80169c <close>

	cprintf("icode: spawn /init\n");
  8000e7:	c7 04 24 b8 2f 80 00 	movl   $0x802fb8,(%esp)
  8000ee:	e8 9a 01 00 00       	call   80028d <cprintf>
	if ((r = spawnl("/init", "init", "initarg1", "initarg2", (char*)0)) < 0)
  8000f3:	c7 44 24 10 00 00 00 	movl   $0x0,0x10(%esp)
  8000fa:	00 
  8000fb:	c7 44 24 0c cc 2f 80 	movl   $0x802fcc,0xc(%esp)
  800102:	00 
  800103:	c7 44 24 08 d5 2f 80 	movl   $0x802fd5,0x8(%esp)
  80010a:	00 
  80010b:	c7 44 24 04 df 2f 80 	movl   $0x802fdf,0x4(%esp)
  800112:	00 
  800113:	c7 04 24 de 2f 80 00 	movl   $0x802fde,(%esp)
  80011a:	e8 f5 1f 00 00       	call   802114 <spawnl>
  80011f:	85 c0                	test   %eax,%eax
  800121:	79 20                	jns    800143 <umain+0x10f>
		panic("icode: spawn /init: %e", r);
  800123:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800127:	c7 44 24 08 e4 2f 80 	movl   $0x802fe4,0x8(%esp)
  80012e:	00 
  80012f:	c7 44 24 04 1a 00 00 	movl   $0x1a,0x4(%esp)
  800136:	00 
  800137:	c7 04 24 84 2f 80 00 	movl   $0x802f84,(%esp)
  80013e:	e8 85 00 00 00       	call   8001c8 <_panic>

	cprintf("icode: exiting\n");
  800143:	c7 04 24 fb 2f 80 00 	movl   $0x802ffb,(%esp)
  80014a:	e8 3e 01 00 00       	call   80028d <cprintf>
}
  80014f:	81 c4 30 02 00 00    	add    $0x230,%esp
  800155:	5b                   	pop    %ebx
  800156:	5e                   	pop    %esi
  800157:	5d                   	pop    %ebp
  800158:	c3                   	ret    
  800159:	00 00                	add    %al,(%eax)
	...

0080015c <libmain>:
volatile struct Env *env;
char *binaryname = "(PROGRAM NAME UNKNOWN)";

void
libmain(int argc, char **argv)
{
  80015c:	55                   	push   %ebp
  80015d:	89 e5                	mov    %esp,%ebp
  80015f:	83 ec 18             	sub    $0x18,%esp
  800162:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  800165:	89 75 fc             	mov    %esi,-0x4(%ebp)
  800168:	8b 75 08             	mov    0x8(%ebp),%esi
  80016b:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	// set env to point at our env structure in envs[].
	// LAB 3: Your code here.
  envid_t envid   = sys_getenvid();
  80016e:	e8 d6 0f 00 00       	call   801149 <sys_getenvid>
	env = &envs [ENVX(envid)];
  800173:	25 ff 03 00 00       	and    $0x3ff,%eax
  800178:	6b c0 7c             	imul   $0x7c,%eax,%eax
  80017b:	05 00 00 c0 ee       	add    $0xeec00000,%eax
  800180:	a3 74 70 80 00       	mov    %eax,0x807074

	// save the name of the program so that panic() can use it
	if (argc > 0)
  800185:	85 f6                	test   %esi,%esi
  800187:	7e 07                	jle    800190 <libmain+0x34>
		binaryname = argv[0];
  800189:	8b 03                	mov    (%ebx),%eax
  80018b:	a3 00 70 80 00       	mov    %eax,0x807000

	// call user main routine
	umain(argc, argv);
  800190:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  800194:	89 34 24             	mov    %esi,(%esp)
  800197:	e8 98 fe ff ff       	call   800034 <umain>

	// exit gracefully
	exit();
  80019c:	e8 0b 00 00 00       	call   8001ac <exit>
}
  8001a1:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  8001a4:	8b 75 fc             	mov    -0x4(%ebp),%esi
  8001a7:	89 ec                	mov    %ebp,%esp
  8001a9:	5d                   	pop    %ebp
  8001aa:	c3                   	ret    
	...

008001ac <exit>:

#include <inc/lib.h>

void
exit(void)
{
  8001ac:	55                   	push   %ebp
  8001ad:	89 e5                	mov    %esp,%ebp
  8001af:	83 ec 18             	sub    $0x18,%esp
	close_all();
  8001b2:	e8 62 15 00 00       	call   801719 <close_all>
	sys_env_destroy(0);
  8001b7:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8001be:	e8 ba 0f 00 00       	call   80117d <sys_env_destroy>
}
  8001c3:	c9                   	leave  
  8001c4:	c3                   	ret    
  8001c5:	00 00                	add    %al,(%eax)
	...

008001c8 <_panic>:
 * It prints "panic: <message>", then causes a breakpoint exception,
 * which causes JOS to enter the JOS kernel monitor.
 */
void
_panic(const char *file, int line, const char *fmt,...)
{
  8001c8:	55                   	push   %ebp
  8001c9:	89 e5                	mov    %esp,%ebp
  8001cb:	53                   	push   %ebx
  8001cc:	83 ec 14             	sub    $0x14,%esp
 * Panic is called on unresolvable fatal errors.
 * It prints "panic: <message>", then causes a breakpoint exception,
 * which causes JOS to enter the JOS kernel monitor.
 */
void
_panic(const char *file, int line, const char *fmt,...)
  8001cf:	8d 5d 14             	lea    0x14(%ebp),%ebx
	va_list ap;

	va_start(ap, fmt);

	// Print the panic message
	if (argv0)
  8001d2:	a1 78 70 80 00       	mov    0x807078,%eax
  8001d7:	85 c0                	test   %eax,%eax
  8001d9:	74 10                	je     8001eb <_panic+0x23>
		cprintf("%s: ", argv0);
  8001db:	89 44 24 04          	mov    %eax,0x4(%esp)
  8001df:	c7 04 24 22 30 80 00 	movl   $0x803022,(%esp)
  8001e6:	e8 a2 00 00 00       	call   80028d <cprintf>
	cprintf("user panic in %s at %s:%d: ", binaryname, file, line);
  8001eb:	8b 45 0c             	mov    0xc(%ebp),%eax
  8001ee:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8001f2:	8b 45 08             	mov    0x8(%ebp),%eax
  8001f5:	89 44 24 08          	mov    %eax,0x8(%esp)
  8001f9:	a1 00 70 80 00       	mov    0x807000,%eax
  8001fe:	89 44 24 04          	mov    %eax,0x4(%esp)
  800202:	c7 04 24 27 30 80 00 	movl   $0x803027,(%esp)
  800209:	e8 7f 00 00 00       	call   80028d <cprintf>
	vcprintf(fmt, ap);
  80020e:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  800212:	8b 45 10             	mov    0x10(%ebp),%eax
  800215:	89 04 24             	mov    %eax,(%esp)
  800218:	e8 0f 00 00 00       	call   80022c <vcprintf>
	cprintf("\n");
  80021d:	c7 04 24 43 35 80 00 	movl   $0x803543,(%esp)
  800224:	e8 64 00 00 00       	call   80028d <cprintf>

	// Cause a breakpoint exception
	while (1)
		asm volatile("int3");
  800229:	cc                   	int3   
  80022a:	eb fd                	jmp    800229 <_panic+0x61>

0080022c <vcprintf>:
	b->cnt++;
}

int
vcprintf(const char *fmt, va_list ap)
{
  80022c:	55                   	push   %ebp
  80022d:	89 e5                	mov    %esp,%ebp
  80022f:	81 ec 28 01 00 00    	sub    $0x128,%esp
	struct printbuf b;

	b.idx = 0;
  800235:	c7 85 f0 fe ff ff 00 	movl   $0x0,-0x110(%ebp)
  80023c:	00 00 00 
	b.cnt = 0;
  80023f:	c7 85 f4 fe ff ff 00 	movl   $0x0,-0x10c(%ebp)
  800246:	00 00 00 
	vprintfmt((void*)putch, &b, fmt, ap);
  800249:	8b 45 0c             	mov    0xc(%ebp),%eax
  80024c:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800250:	8b 45 08             	mov    0x8(%ebp),%eax
  800253:	89 44 24 08          	mov    %eax,0x8(%esp)
  800257:	8d 85 f0 fe ff ff    	lea    -0x110(%ebp),%eax
  80025d:	89 44 24 04          	mov    %eax,0x4(%esp)
  800261:	c7 04 24 a7 02 80 00 	movl   $0x8002a7,(%esp)
  800268:	e8 d0 01 00 00       	call   80043d <vprintfmt>
	sys_cputs(b.buf, b.idx);
  80026d:	8b 85 f0 fe ff ff    	mov    -0x110(%ebp),%eax
  800273:	89 44 24 04          	mov    %eax,0x4(%esp)
  800277:	8d 85 f8 fe ff ff    	lea    -0x108(%ebp),%eax
  80027d:	89 04 24             	mov    %eax,(%esp)
  800280:	e8 cb 0a 00 00       	call   800d50 <sys_cputs>

	return b.cnt;
}
  800285:	8b 85 f4 fe ff ff    	mov    -0x10c(%ebp),%eax
  80028b:	c9                   	leave  
  80028c:	c3                   	ret    

0080028d <cprintf>:

int
cprintf(const char *fmt, ...)
{
  80028d:	55                   	push   %ebp
  80028e:	89 e5                	mov    %esp,%ebp
  800290:	83 ec 18             	sub    $0x18,%esp

	return b.cnt;
}

int
cprintf(const char *fmt, ...)
  800293:	8d 45 0c             	lea    0xc(%ebp),%eax
{
	va_list ap;
	int cnt;

	va_start(ap, fmt);
	cnt = vcprintf(fmt, ap);
  800296:	89 44 24 04          	mov    %eax,0x4(%esp)
  80029a:	8b 45 08             	mov    0x8(%ebp),%eax
  80029d:	89 04 24             	mov    %eax,(%esp)
  8002a0:	e8 87 ff ff ff       	call   80022c <vcprintf>
	va_end(ap);

	return cnt;
}
  8002a5:	c9                   	leave  
  8002a6:	c3                   	ret    

008002a7 <putch>:
};


static void
putch(int ch, struct printbuf *b)
{
  8002a7:	55                   	push   %ebp
  8002a8:	89 e5                	mov    %esp,%ebp
  8002aa:	53                   	push   %ebx
  8002ab:	83 ec 14             	sub    $0x14,%esp
  8002ae:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	b->buf[b->idx++] = ch;
  8002b1:	8b 03                	mov    (%ebx),%eax
  8002b3:	8b 55 08             	mov    0x8(%ebp),%edx
  8002b6:	88 54 03 08          	mov    %dl,0x8(%ebx,%eax,1)
  8002ba:	83 c0 01             	add    $0x1,%eax
  8002bd:	89 03                	mov    %eax,(%ebx)
	if (b->idx == 256-1) {
  8002bf:	3d ff 00 00 00       	cmp    $0xff,%eax
  8002c4:	75 19                	jne    8002df <putch+0x38>
		sys_cputs(b->buf, b->idx);
  8002c6:	c7 44 24 04 ff 00 00 	movl   $0xff,0x4(%esp)
  8002cd:	00 
  8002ce:	8d 43 08             	lea    0x8(%ebx),%eax
  8002d1:	89 04 24             	mov    %eax,(%esp)
  8002d4:	e8 77 0a 00 00       	call   800d50 <sys_cputs>
		b->idx = 0;
  8002d9:	c7 03 00 00 00 00    	movl   $0x0,(%ebx)
	}
	b->cnt++;
  8002df:	83 43 04 01          	addl   $0x1,0x4(%ebx)
}
  8002e3:	83 c4 14             	add    $0x14,%esp
  8002e6:	5b                   	pop    %ebx
  8002e7:	5d                   	pop    %ebp
  8002e8:	c3                   	ret    
  8002e9:	00 00                	add    %al,(%eax)
  8002eb:	00 00                	add    %al,(%eax)
  8002ed:	00 00                	add    %al,(%eax)
	...

008002f0 <printnum>:
 * using specified putch function and associated pointer putdat.
 */
static void
printnum(void (*putch)(int, void*), void *putdat,
	 unsigned long long num, unsigned base, int width, int padc)
{
  8002f0:	55                   	push   %ebp
  8002f1:	89 e5                	mov    %esp,%ebp
  8002f3:	57                   	push   %edi
  8002f4:	56                   	push   %esi
  8002f5:	53                   	push   %ebx
  8002f6:	83 ec 4c             	sub    $0x4c,%esp
  8002f9:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  8002fc:	89 d6                	mov    %edx,%esi
  8002fe:	8b 45 08             	mov    0x8(%ebp),%eax
  800301:	89 45 d8             	mov    %eax,-0x28(%ebp)
  800304:	8b 55 0c             	mov    0xc(%ebp),%edx
  800307:	89 55 e0             	mov    %edx,-0x20(%ebp)
  80030a:	8b 45 10             	mov    0x10(%ebp),%eax
  80030d:	8b 5d 14             	mov    0x14(%ebp),%ebx
  800310:	8b 7d 18             	mov    0x18(%ebp),%edi
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
  800313:	89 45 dc             	mov    %eax,-0x24(%ebp)
  800316:	b9 00 00 00 00       	mov    $0x0,%ecx
  80031b:	39 d1                	cmp    %edx,%ecx
  80031d:	72 15                	jb     800334 <printnum+0x44>
  80031f:	77 07                	ja     800328 <printnum+0x38>
  800321:	8b 55 d8             	mov    -0x28(%ebp),%edx
  800324:	39 d0                	cmp    %edx,%eax
  800326:	76 0c                	jbe    800334 <printnum+0x44>
		printnum(putch, putdat, num / base, base, width - 1, padc);
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
  800328:	83 eb 01             	sub    $0x1,%ebx
  80032b:	85 db                	test   %ebx,%ebx
  80032d:	8d 76 00             	lea    0x0(%esi),%esi
  800330:	7f 61                	jg     800393 <printnum+0xa3>
  800332:	eb 70                	jmp    8003a4 <printnum+0xb4>
printnum(void (*putch)(int, void*), void *putdat,
	 unsigned long long num, unsigned base, int width, int padc)
{
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
		printnum(putch, putdat, num / base, base, width - 1, padc);
  800334:	89 7c 24 10          	mov    %edi,0x10(%esp)
  800338:	83 eb 01             	sub    $0x1,%ebx
  80033b:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  80033f:	89 44 24 08          	mov    %eax,0x8(%esp)
  800343:	8b 4c 24 08          	mov    0x8(%esp),%ecx
  800347:	8b 5c 24 0c          	mov    0xc(%esp),%ebx
  80034b:	89 4d d0             	mov    %ecx,-0x30(%ebp)
  80034e:	89 5d d4             	mov    %ebx,-0x2c(%ebp)
  800351:	8b 5d dc             	mov    -0x24(%ebp),%ebx
  800354:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  800358:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  80035f:	00 
  800360:	8b 45 d8             	mov    -0x28(%ebp),%eax
  800363:	89 04 24             	mov    %eax,(%esp)
  800366:	8b 55 e0             	mov    -0x20(%ebp),%edx
  800369:	89 54 24 04          	mov    %edx,0x4(%esp)
  80036d:	e8 4e 29 00 00       	call   802cc0 <__udivdi3>
  800372:	8b 4d d0             	mov    -0x30(%ebp),%ecx
  800375:	8b 5d d4             	mov    -0x2c(%ebp),%ebx
  800378:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  80037c:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  800380:	89 04 24             	mov    %eax,(%esp)
  800383:	89 54 24 04          	mov    %edx,0x4(%esp)
  800387:	89 f2                	mov    %esi,%edx
  800389:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  80038c:	e8 5f ff ff ff       	call   8002f0 <printnum>
  800391:	eb 11                	jmp    8003a4 <printnum+0xb4>
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
			putch(padc, putdat);
  800393:	89 74 24 04          	mov    %esi,0x4(%esp)
  800397:	89 3c 24             	mov    %edi,(%esp)
  80039a:	ff 55 e4             	call   *-0x1c(%ebp)
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
		printnum(putch, putdat, num / base, base, width - 1, padc);
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
  80039d:	83 eb 01             	sub    $0x1,%ebx
  8003a0:	85 db                	test   %ebx,%ebx
  8003a2:	7f ef                	jg     800393 <printnum+0xa3>
			putch(padc, putdat);
	}

	// then print this (the least significant) digit
	putch("0123456789abcdef"[num % base], putdat);
  8003a4:	89 74 24 04          	mov    %esi,0x4(%esp)
  8003a8:	8b 74 24 04          	mov    0x4(%esp),%esi
  8003ac:	8b 45 dc             	mov    -0x24(%ebp),%eax
  8003af:	89 44 24 08          	mov    %eax,0x8(%esp)
  8003b3:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  8003ba:	00 
  8003bb:	8b 55 d8             	mov    -0x28(%ebp),%edx
  8003be:	89 14 24             	mov    %edx,(%esp)
  8003c1:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  8003c4:	89 4c 24 04          	mov    %ecx,0x4(%esp)
  8003c8:	e8 23 2a 00 00       	call   802df0 <__umoddi3>
  8003cd:	89 74 24 04          	mov    %esi,0x4(%esp)
  8003d1:	0f be 80 43 30 80 00 	movsbl 0x803043(%eax),%eax
  8003d8:	89 04 24             	mov    %eax,(%esp)
  8003db:	ff 55 e4             	call   *-0x1c(%ebp)
}
  8003de:	83 c4 4c             	add    $0x4c,%esp
  8003e1:	5b                   	pop    %ebx
  8003e2:	5e                   	pop    %esi
  8003e3:	5f                   	pop    %edi
  8003e4:	5d                   	pop    %ebp
  8003e5:	c3                   	ret    

008003e6 <getuint>:

// Get an unsigned int of various possible sizes from a varargs list,
// depending on the lflag parameter.
static unsigned long long
getuint(va_list *ap, int lflag)
{
  8003e6:	55                   	push   %ebp
  8003e7:	89 e5                	mov    %esp,%ebp
	if (lflag >= 2)
  8003e9:	83 fa 01             	cmp    $0x1,%edx
  8003ec:	7e 0e                	jle    8003fc <getuint+0x16>
		return va_arg(*ap, unsigned long long);
  8003ee:	8b 10                	mov    (%eax),%edx
  8003f0:	8d 4a 08             	lea    0x8(%edx),%ecx
  8003f3:	89 08                	mov    %ecx,(%eax)
  8003f5:	8b 02                	mov    (%edx),%eax
  8003f7:	8b 52 04             	mov    0x4(%edx),%edx
  8003fa:	eb 22                	jmp    80041e <getuint+0x38>
	else if (lflag)
  8003fc:	85 d2                	test   %edx,%edx
  8003fe:	74 10                	je     800410 <getuint+0x2a>
		return va_arg(*ap, unsigned long);
  800400:	8b 10                	mov    (%eax),%edx
  800402:	8d 4a 04             	lea    0x4(%edx),%ecx
  800405:	89 08                	mov    %ecx,(%eax)
  800407:	8b 02                	mov    (%edx),%eax
  800409:	ba 00 00 00 00       	mov    $0x0,%edx
  80040e:	eb 0e                	jmp    80041e <getuint+0x38>
	else
		return va_arg(*ap, unsigned int);
  800410:	8b 10                	mov    (%eax),%edx
  800412:	8d 4a 04             	lea    0x4(%edx),%ecx
  800415:	89 08                	mov    %ecx,(%eax)
  800417:	8b 02                	mov    (%edx),%eax
  800419:	ba 00 00 00 00       	mov    $0x0,%edx
}
  80041e:	5d                   	pop    %ebp
  80041f:	c3                   	ret    

00800420 <sprintputch>:
	int cnt;
};

static void
sprintputch(int ch, struct sprintbuf *b)
{
  800420:	55                   	push   %ebp
  800421:	89 e5                	mov    %esp,%ebp
  800423:	8b 45 0c             	mov    0xc(%ebp),%eax
	b->cnt++;
  800426:	83 40 08 01          	addl   $0x1,0x8(%eax)
	if (b->buf < b->ebuf)
  80042a:	8b 10                	mov    (%eax),%edx
  80042c:	3b 50 04             	cmp    0x4(%eax),%edx
  80042f:	73 0a                	jae    80043b <sprintputch+0x1b>
		*b->buf++ = ch;
  800431:	8b 4d 08             	mov    0x8(%ebp),%ecx
  800434:	88 0a                	mov    %cl,(%edx)
  800436:	83 c2 01             	add    $0x1,%edx
  800439:	89 10                	mov    %edx,(%eax)
}
  80043b:	5d                   	pop    %ebp
  80043c:	c3                   	ret    

0080043d <vprintfmt>:
// Main function to format and print a string.
void printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...);

void
vprintfmt(void (*putch)(int, void*), void *putdat, const char *fmt, va_list ap)
{
  80043d:	55                   	push   %ebp
  80043e:	89 e5                	mov    %esp,%ebp
  800440:	57                   	push   %edi
  800441:	56                   	push   %esi
  800442:	53                   	push   %ebx
  800443:	83 ec 5c             	sub    $0x5c,%esp
  800446:	8b 7d 08             	mov    0x8(%ebp),%edi
  800449:	8b 75 0c             	mov    0xc(%ebp),%esi
  80044c:	8b 5d 10             	mov    0x10(%ebp),%ebx
		case '#':
			altflag = 1;
			goto reswitch;

		process_precision:
			if (width < 0)
  80044f:	c7 45 c8 ff ff ff ff 	movl   $0xffffffff,-0x38(%ebp)
  800456:	eb 11                	jmp    800469 <vprintfmt+0x2c>
	int base, lflag, width, precision, altflag;
	char padc;

	while (1) {
		while ((ch = *(unsigned char *) fmt++) != '%') {
			if (ch == '\0')
  800458:	85 c0                	test   %eax,%eax
  80045a:	0f 84 f9 03 00 00    	je     800859 <vprintfmt+0x41c>
				return;
			putch(ch, putdat);
  800460:	89 74 24 04          	mov    %esi,0x4(%esp)
  800464:	89 04 24             	mov    %eax,(%esp)
  800467:	ff d7                	call   *%edi
	unsigned long long num;
	int base, lflag, width, precision, altflag;
	char padc;

	while (1) {
		while ((ch = *(unsigned char *) fmt++) != '%') {
  800469:	0f b6 03             	movzbl (%ebx),%eax
  80046c:	83 c3 01             	add    $0x1,%ebx
  80046f:	83 f8 25             	cmp    $0x25,%eax
  800472:	75 e4                	jne    800458 <vprintfmt+0x1b>
  800474:	c6 45 d4 20          	movb   $0x20,-0x2c(%ebp)
  800478:	c7 45 d8 00 00 00 00 	movl   $0x0,-0x28(%ebp)
  80047f:	c7 45 d0 ff ff ff ff 	movl   $0xffffffff,-0x30(%ebp)
  800486:	c7 45 e4 ff ff ff ff 	movl   $0xffffffff,-0x1c(%ebp)
  80048d:	b9 00 00 00 00       	mov    $0x0,%ecx
  800492:	eb 06                	jmp    80049a <vprintfmt+0x5d>
  800494:	c6 45 d4 2d          	movb   $0x2d,-0x2c(%ebp)
  800498:	89 c3                	mov    %eax,%ebx
		width = -1;
		precision = -1;
		lflag = 0;
		altflag = 0;
	reswitch:
		switch (ch = *(unsigned char *) fmt++) {
  80049a:	0f b6 13             	movzbl (%ebx),%edx
  80049d:	0f b6 c2             	movzbl %dl,%eax
  8004a0:	89 45 e0             	mov    %eax,-0x20(%ebp)
  8004a3:	8d 43 01             	lea    0x1(%ebx),%eax
  8004a6:	83 ea 23             	sub    $0x23,%edx
  8004a9:	80 fa 55             	cmp    $0x55,%dl
  8004ac:	0f 87 8a 03 00 00    	ja     80083c <vprintfmt+0x3ff>
  8004b2:	0f b6 d2             	movzbl %dl,%edx
  8004b5:	ff 24 95 80 31 80 00 	jmp    *0x803180(,%edx,4)
  8004bc:	c6 45 d4 30          	movb   $0x30,-0x2c(%ebp)
  8004c0:	eb d6                	jmp    800498 <vprintfmt+0x5b>
		case '6':
		case '7':
		case '8':
		case '9':
			for (precision = 0; ; ++fmt) {
				precision = precision * 10 + ch - '0';
  8004c2:	8b 55 e0             	mov    -0x20(%ebp),%edx
  8004c5:	83 ea 30             	sub    $0x30,%edx
  8004c8:	89 55 d0             	mov    %edx,-0x30(%ebp)
				ch = *fmt;
  8004cb:	0f be 10             	movsbl (%eax),%edx
				if (ch < '0' || ch > '9')
  8004ce:	8d 5a d0             	lea    -0x30(%edx),%ebx
  8004d1:	83 fb 09             	cmp    $0x9,%ebx
  8004d4:	77 54                	ja     80052a <vprintfmt+0xed>
  8004d6:	89 4d e0             	mov    %ecx,-0x20(%ebp)
  8004d9:	8b 4d d0             	mov    -0x30(%ebp),%ecx
		case '5':
		case '6':
		case '7':
		case '8':
		case '9':
			for (precision = 0; ; ++fmt) {
  8004dc:	83 c0 01             	add    $0x1,%eax
				precision = precision * 10 + ch - '0';
  8004df:	8d 0c 89             	lea    (%ecx,%ecx,4),%ecx
  8004e2:	8d 4c 4a d0          	lea    -0x30(%edx,%ecx,2),%ecx
				ch = *fmt;
  8004e6:	0f be 10             	movsbl (%eax),%edx
				if (ch < '0' || ch > '9')
  8004e9:	8d 5a d0             	lea    -0x30(%edx),%ebx
  8004ec:	83 fb 09             	cmp    $0x9,%ebx
  8004ef:	76 eb                	jbe    8004dc <vprintfmt+0x9f>
  8004f1:	89 4d d0             	mov    %ecx,-0x30(%ebp)
  8004f4:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  8004f7:	eb 31                	jmp    80052a <vprintfmt+0xed>
					break;
			}
			goto process_precision;

		case '*':
			precision = va_arg(ap, int);
  8004f9:	8b 55 14             	mov    0x14(%ebp),%edx
  8004fc:	8d 5a 04             	lea    0x4(%edx),%ebx
  8004ff:	89 5d 14             	mov    %ebx,0x14(%ebp)
  800502:	8b 12                	mov    (%edx),%edx
  800504:	89 55 d0             	mov    %edx,-0x30(%ebp)
			goto process_precision;
  800507:	eb 21                	jmp    80052a <vprintfmt+0xed>

		case '.':
			if (width < 0)
  800509:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  80050d:	ba 00 00 00 00       	mov    $0x0,%edx
  800512:	0f 49 55 e4          	cmovns -0x1c(%ebp),%edx
  800516:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  800519:	e9 7a ff ff ff       	jmp    800498 <vprintfmt+0x5b>
  80051e:	c7 45 d8 01 00 00 00 	movl   $0x1,-0x28(%ebp)
				width = 0;
			goto reswitch;

		case '#':
			altflag = 1;
			goto reswitch;
  800525:	e9 6e ff ff ff       	jmp    800498 <vprintfmt+0x5b>

		process_precision:
			if (width < 0)
  80052a:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  80052e:	0f 89 64 ff ff ff    	jns    800498 <vprintfmt+0x5b>
  800534:	8b 55 d0             	mov    -0x30(%ebp),%edx
  800537:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  80053a:	8b 55 c8             	mov    -0x38(%ebp),%edx
  80053d:	89 55 d0             	mov    %edx,-0x30(%ebp)
  800540:	e9 53 ff ff ff       	jmp    800498 <vprintfmt+0x5b>
				width = precision, precision = -1;
			goto reswitch;

		// long flag (doubled for long long)
		case 'l':
			lflag++;
  800545:	83 c1 01             	add    $0x1,%ecx
			goto reswitch;
  800548:	e9 4b ff ff ff       	jmp    800498 <vprintfmt+0x5b>
  80054d:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// character
		case 'c':
			putch(va_arg(ap, int), putdat);
  800550:	8b 45 14             	mov    0x14(%ebp),%eax
  800553:	8d 50 04             	lea    0x4(%eax),%edx
  800556:	89 55 14             	mov    %edx,0x14(%ebp)
  800559:	89 74 24 04          	mov    %esi,0x4(%esp)
  80055d:	8b 00                	mov    (%eax),%eax
  80055f:	89 04 24             	mov    %eax,(%esp)
  800562:	ff d7                	call   *%edi
  800564:	8b 5d cc             	mov    -0x34(%ebp),%ebx
			break;
  800567:	e9 fd fe ff ff       	jmp    800469 <vprintfmt+0x2c>
  80056c:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// error message
		case 'e':
			err = va_arg(ap, int);
  80056f:	8b 45 14             	mov    0x14(%ebp),%eax
  800572:	8d 50 04             	lea    0x4(%eax),%edx
  800575:	89 55 14             	mov    %edx,0x14(%ebp)
  800578:	8b 00                	mov    (%eax),%eax
  80057a:	89 c2                	mov    %eax,%edx
  80057c:	c1 fa 1f             	sar    $0x1f,%edx
  80057f:	31 d0                	xor    %edx,%eax
  800581:	29 d0                	sub    %edx,%eax
			if (err < 0)
				err = -err;
			if (err > MAXERROR || (p = error_string[err]) == NULL)
  800583:	83 f8 12             	cmp    $0x12,%eax
  800586:	7f 0b                	jg     800593 <vprintfmt+0x156>
  800588:	8b 14 85 e0 32 80 00 	mov    0x8032e0(,%eax,4),%edx
  80058f:	85 d2                	test   %edx,%edx
  800591:	75 20                	jne    8005b3 <vprintfmt+0x176>
				printfmt(putch, putdat, "error %d", err);
  800593:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800597:	c7 44 24 08 54 30 80 	movl   $0x803054,0x8(%esp)
  80059e:	00 
  80059f:	89 74 24 04          	mov    %esi,0x4(%esp)
  8005a3:	89 3c 24             	mov    %edi,(%esp)
  8005a6:	e8 36 03 00 00       	call   8008e1 <printfmt>
  8005ab:	8b 5d cc             	mov    -0x34(%ebp),%ebx
		// error message
		case 'e':
			err = va_arg(ap, int);
			if (err < 0)
				err = -err;
			if (err > MAXERROR || (p = error_string[err]) == NULL)
  8005ae:	e9 b6 fe ff ff       	jmp    800469 <vprintfmt+0x2c>
				printfmt(putch, putdat, "error %d", err);
			else
				printfmt(putch, putdat, "%s", p);
  8005b3:	89 54 24 0c          	mov    %edx,0xc(%esp)
  8005b7:	c7 44 24 08 34 34 80 	movl   $0x803434,0x8(%esp)
  8005be:	00 
  8005bf:	89 74 24 04          	mov    %esi,0x4(%esp)
  8005c3:	89 3c 24             	mov    %edi,(%esp)
  8005c6:	e8 16 03 00 00       	call   8008e1 <printfmt>
  8005cb:	8b 5d cc             	mov    -0x34(%ebp),%ebx
  8005ce:	e9 96 fe ff ff       	jmp    800469 <vprintfmt+0x2c>
  8005d3:	89 45 cc             	mov    %eax,-0x34(%ebp)
  8005d6:	89 c3                	mov    %eax,%ebx
  8005d8:	8b 4d d0             	mov    -0x30(%ebp),%ecx
  8005db:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8005de:	89 45 c4             	mov    %eax,-0x3c(%ebp)
			break;

		// string
		case 's':
			if ((p = va_arg(ap, char *)) == NULL)
  8005e1:	8b 45 14             	mov    0x14(%ebp),%eax
  8005e4:	8d 50 04             	lea    0x4(%eax),%edx
  8005e7:	89 55 14             	mov    %edx,0x14(%ebp)
  8005ea:	8b 00                	mov    (%eax),%eax
  8005ec:	89 45 e0             	mov    %eax,-0x20(%ebp)
  8005ef:	85 c0                	test   %eax,%eax
  8005f1:	b8 5d 30 80 00       	mov    $0x80305d,%eax
  8005f6:	0f 45 45 e0          	cmovne -0x20(%ebp),%eax
  8005fa:	89 45 e0             	mov    %eax,-0x20(%ebp)
				p = "(null)";
			if (width > 0 && padc != '-')
  8005fd:	83 7d c4 00          	cmpl   $0x0,-0x3c(%ebp)
  800601:	7e 06                	jle    800609 <vprintfmt+0x1cc>
  800603:	80 7d d4 2d          	cmpb   $0x2d,-0x2c(%ebp)
  800607:	75 13                	jne    80061c <vprintfmt+0x1df>
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  800609:	8b 55 e0             	mov    -0x20(%ebp),%edx
  80060c:	0f be 02             	movsbl (%edx),%eax
  80060f:	85 c0                	test   %eax,%eax
  800611:	0f 85 9b 00 00 00    	jne    8006b2 <vprintfmt+0x275>
  800617:	e9 88 00 00 00       	jmp    8006a4 <vprintfmt+0x267>
		// string
		case 's':
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
  80061c:	89 4c 24 04          	mov    %ecx,0x4(%esp)
  800620:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  800623:	89 0c 24             	mov    %ecx,(%esp)
  800626:	e8 00 03 00 00       	call   80092b <strnlen>
  80062b:	8b 55 c4             	mov    -0x3c(%ebp),%edx
  80062e:	29 c2                	sub    %eax,%edx
  800630:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  800633:	85 d2                	test   %edx,%edx
  800635:	7e d2                	jle    800609 <vprintfmt+0x1cc>
					putch(padc, putdat);
  800637:	0f be 4d d4          	movsbl -0x2c(%ebp),%ecx
  80063b:	89 4d d4             	mov    %ecx,-0x2c(%ebp)
  80063e:	89 5d c4             	mov    %ebx,-0x3c(%ebp)
  800641:	89 d3                	mov    %edx,%ebx
  800643:	89 74 24 04          	mov    %esi,0x4(%esp)
  800647:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  80064a:	89 04 24             	mov    %eax,(%esp)
  80064d:	ff d7                	call   *%edi
		// string
		case 's':
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
  80064f:	83 eb 01             	sub    $0x1,%ebx
  800652:	85 db                	test   %ebx,%ebx
  800654:	7f ed                	jg     800643 <vprintfmt+0x206>
  800656:	8b 5d c4             	mov    -0x3c(%ebp),%ebx
  800659:	c7 45 e4 00 00 00 00 	movl   $0x0,-0x1c(%ebp)
  800660:	eb a7                	jmp    800609 <vprintfmt+0x1cc>
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
				if (altflag && (ch < ' ' || ch > '~'))
  800662:	83 7d d8 00          	cmpl   $0x0,-0x28(%ebp)
  800666:	74 1a                	je     800682 <vprintfmt+0x245>
  800668:	8d 50 e0             	lea    -0x20(%eax),%edx
  80066b:	83 fa 5e             	cmp    $0x5e,%edx
  80066e:	76 12                	jbe    800682 <vprintfmt+0x245>
					putch('?', putdat);
  800670:	89 7c 24 04          	mov    %edi,0x4(%esp)
  800674:	c7 04 24 3f 00 00 00 	movl   $0x3f,(%esp)
  80067b:	ff 55 e0             	call   *-0x20(%ebp)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
				if (altflag && (ch < ' ' || ch > '~'))
  80067e:	66 90                	xchg   %ax,%ax
  800680:	eb 0a                	jmp    80068c <vprintfmt+0x24f>
					putch('?', putdat);
				else
					putch(ch, putdat);
  800682:	89 7c 24 04          	mov    %edi,0x4(%esp)
  800686:	89 04 24             	mov    %eax,(%esp)
  800689:	ff 55 e0             	call   *-0x20(%ebp)
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  80068c:	83 6d e4 01          	subl   $0x1,-0x1c(%ebp)
  800690:	0f be 03             	movsbl (%ebx),%eax
  800693:	85 c0                	test   %eax,%eax
  800695:	74 05                	je     80069c <vprintfmt+0x25f>
  800697:	83 c3 01             	add    $0x1,%ebx
  80069a:	eb 29                	jmp    8006c5 <vprintfmt+0x288>
  80069c:	89 fe                	mov    %edi,%esi
  80069e:	8b 7d e0             	mov    -0x20(%ebp),%edi
  8006a1:	8b 5d d0             	mov    -0x30(%ebp),%ebx
				if (altflag && (ch < ' ' || ch > '~'))
					putch('?', putdat);
				else
					putch(ch, putdat);
			for (; width > 0; width--)
  8006a4:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  8006a8:	7f 2e                	jg     8006d8 <vprintfmt+0x29b>
  8006aa:	8b 5d cc             	mov    -0x34(%ebp),%ebx
  8006ad:	e9 b7 fd ff ff       	jmp    800469 <vprintfmt+0x2c>
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  8006b2:	8b 55 e0             	mov    -0x20(%ebp),%edx
  8006b5:	83 c2 01             	add    $0x1,%edx
  8006b8:	89 7d e0             	mov    %edi,-0x20(%ebp)
  8006bb:	89 f7                	mov    %esi,%edi
  8006bd:	8b 75 d0             	mov    -0x30(%ebp),%esi
  8006c0:	89 5d d0             	mov    %ebx,-0x30(%ebp)
  8006c3:	89 d3                	mov    %edx,%ebx
  8006c5:	85 f6                	test   %esi,%esi
  8006c7:	78 99                	js     800662 <vprintfmt+0x225>
  8006c9:	83 ee 01             	sub    $0x1,%esi
  8006cc:	79 94                	jns    800662 <vprintfmt+0x225>
  8006ce:	89 fe                	mov    %edi,%esi
  8006d0:	8b 7d e0             	mov    -0x20(%ebp),%edi
  8006d3:	8b 5d d0             	mov    -0x30(%ebp),%ebx
  8006d6:	eb cc                	jmp    8006a4 <vprintfmt+0x267>
  8006d8:	89 5d d8             	mov    %ebx,-0x28(%ebp)
  8006db:	8b 5d e4             	mov    -0x1c(%ebp),%ebx
				if (altflag && (ch < ' ' || ch > '~'))
					putch('?', putdat);
				else
					putch(ch, putdat);
			for (; width > 0; width--)
				putch(' ', putdat);
  8006de:	89 74 24 04          	mov    %esi,0x4(%esp)
  8006e2:	c7 04 24 20 00 00 00 	movl   $0x20,(%esp)
  8006e9:	ff d7                	call   *%edi
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
				if (altflag && (ch < ' ' || ch > '~'))
					putch('?', putdat);
				else
					putch(ch, putdat);
			for (; width > 0; width--)
  8006eb:	83 eb 01             	sub    $0x1,%ebx
  8006ee:	85 db                	test   %ebx,%ebx
  8006f0:	7f ec                	jg     8006de <vprintfmt+0x2a1>
  8006f2:	8b 5d d8             	mov    -0x28(%ebp),%ebx
  8006f5:	e9 6f fd ff ff       	jmp    800469 <vprintfmt+0x2c>
  8006fa:	89 45 cc             	mov    %eax,-0x34(%ebp)
// Same as getuint but signed - can't use getuint
// because of sign extension
static long long
getint(va_list *ap, int lflag)
{
	if (lflag >= 2)
  8006fd:	83 f9 01             	cmp    $0x1,%ecx
  800700:	7e 16                	jle    800718 <vprintfmt+0x2db>
		return va_arg(*ap, long long);
  800702:	8b 45 14             	mov    0x14(%ebp),%eax
  800705:	8d 50 08             	lea    0x8(%eax),%edx
  800708:	89 55 14             	mov    %edx,0x14(%ebp)
  80070b:	8b 10                	mov    (%eax),%edx
  80070d:	8b 48 04             	mov    0x4(%eax),%ecx
  800710:	89 55 d8             	mov    %edx,-0x28(%ebp)
  800713:	89 4d dc             	mov    %ecx,-0x24(%ebp)
  800716:	eb 32                	jmp    80074a <vprintfmt+0x30d>
	else if (lflag)
  800718:	85 c9                	test   %ecx,%ecx
  80071a:	74 18                	je     800734 <vprintfmt+0x2f7>
		return va_arg(*ap, long);
  80071c:	8b 45 14             	mov    0x14(%ebp),%eax
  80071f:	8d 50 04             	lea    0x4(%eax),%edx
  800722:	89 55 14             	mov    %edx,0x14(%ebp)
  800725:	8b 00                	mov    (%eax),%eax
  800727:	89 45 d8             	mov    %eax,-0x28(%ebp)
  80072a:	89 c1                	mov    %eax,%ecx
  80072c:	c1 f9 1f             	sar    $0x1f,%ecx
  80072f:	89 4d dc             	mov    %ecx,-0x24(%ebp)
  800732:	eb 16                	jmp    80074a <vprintfmt+0x30d>
	else
		return va_arg(*ap, int);
  800734:	8b 45 14             	mov    0x14(%ebp),%eax
  800737:	8d 50 04             	lea    0x4(%eax),%edx
  80073a:	89 55 14             	mov    %edx,0x14(%ebp)
  80073d:	8b 00                	mov    (%eax),%eax
  80073f:	89 45 d8             	mov    %eax,-0x28(%ebp)
  800742:	89 c2                	mov    %eax,%edx
  800744:	c1 fa 1f             	sar    $0x1f,%edx
  800747:	89 55 dc             	mov    %edx,-0x24(%ebp)
				putch(' ', putdat);
			break;

		// (signed) decimal
		case 'd':
			num = getint(&ap, lflag);
  80074a:	8b 4d d8             	mov    -0x28(%ebp),%ecx
  80074d:	8b 5d dc             	mov    -0x24(%ebp),%ebx
  800750:	b8 0a 00 00 00       	mov    $0xa,%eax
			if ((long long) num < 0) {
  800755:	83 7d dc 00          	cmpl   $0x0,-0x24(%ebp)
  800759:	0f 89 9b 00 00 00    	jns    8007fa <vprintfmt+0x3bd>
				putch('-', putdat);
  80075f:	89 74 24 04          	mov    %esi,0x4(%esp)
  800763:	c7 04 24 2d 00 00 00 	movl   $0x2d,(%esp)
  80076a:	ff d7                	call   *%edi
				num = -(long long) num;
  80076c:	8b 4d d8             	mov    -0x28(%ebp),%ecx
  80076f:	8b 5d dc             	mov    -0x24(%ebp),%ebx
  800772:	f7 d9                	neg    %ecx
  800774:	83 d3 00             	adc    $0x0,%ebx
  800777:	f7 db                	neg    %ebx
  800779:	b8 0a 00 00 00       	mov    $0xa,%eax
  80077e:	eb 7a                	jmp    8007fa <vprintfmt+0x3bd>
  800780:	89 45 cc             	mov    %eax,-0x34(%ebp)
			base = 10;
			goto number;

		// unsigned decimal
		case 'u':
			num = getuint(&ap, lflag);
  800783:	89 ca                	mov    %ecx,%edx
  800785:	8d 45 14             	lea    0x14(%ebp),%eax
  800788:	e8 59 fc ff ff       	call   8003e6 <getuint>
  80078d:	89 c1                	mov    %eax,%ecx
  80078f:	89 d3                	mov    %edx,%ebx
  800791:	b8 0a 00 00 00       	mov    $0xa,%eax
			base = 10;
			goto number;
  800796:	eb 62                	jmp    8007fa <vprintfmt+0x3bd>
  800798:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// (unsigned) octal
		case 'o':
			num = getuint(&ap, lflag);
  80079b:	89 ca                	mov    %ecx,%edx
  80079d:	8d 45 14             	lea    0x14(%ebp),%eax
  8007a0:	e8 41 fc ff ff       	call   8003e6 <getuint>
  8007a5:	89 c1                	mov    %eax,%ecx
  8007a7:	89 d3                	mov    %edx,%ebx
  8007a9:	b8 08 00 00 00       	mov    $0x8,%eax
			base = 8;
			goto number;
  8007ae:	eb 4a                	jmp    8007fa <vprintfmt+0x3bd>
  8007b0:	89 45 cc             	mov    %eax,-0x34(%ebp)
			break;
			**/

		// pointer
		case 'p':
			putch('0', putdat);
  8007b3:	89 74 24 04          	mov    %esi,0x4(%esp)
  8007b7:	c7 04 24 30 00 00 00 	movl   $0x30,(%esp)
  8007be:	ff d7                	call   *%edi
			putch('x', putdat);
  8007c0:	89 74 24 04          	mov    %esi,0x4(%esp)
  8007c4:	c7 04 24 78 00 00 00 	movl   $0x78,(%esp)
  8007cb:	ff d7                	call   *%edi
			num = (unsigned long long)
  8007cd:	8b 45 14             	mov    0x14(%ebp),%eax
  8007d0:	8d 50 04             	lea    0x4(%eax),%edx
  8007d3:	89 55 14             	mov    %edx,0x14(%ebp)
  8007d6:	8b 08                	mov    (%eax),%ecx
  8007d8:	bb 00 00 00 00       	mov    $0x0,%ebx
  8007dd:	b8 10 00 00 00       	mov    $0x10,%eax
				(uintptr_t) va_arg(ap, void *);
			base = 16;
			goto number;
  8007e2:	eb 16                	jmp    8007fa <vprintfmt+0x3bd>
  8007e4:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// (unsigned) hexadecimal
		case 'x':
			num = getuint(&ap, lflag);
  8007e7:	89 ca                	mov    %ecx,%edx
  8007e9:	8d 45 14             	lea    0x14(%ebp),%eax
  8007ec:	e8 f5 fb ff ff       	call   8003e6 <getuint>
  8007f1:	89 c1                	mov    %eax,%ecx
  8007f3:	89 d3                	mov    %edx,%ebx
  8007f5:	b8 10 00 00 00       	mov    $0x10,%eax
			base = 16;
		number:
			printnum(putch, putdat, num, base, width, padc);
  8007fa:	0f be 55 d4          	movsbl -0x2c(%ebp),%edx
  8007fe:	89 54 24 10          	mov    %edx,0x10(%esp)
  800802:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  800805:	89 54 24 0c          	mov    %edx,0xc(%esp)
  800809:	89 44 24 08          	mov    %eax,0x8(%esp)
  80080d:	89 0c 24             	mov    %ecx,(%esp)
  800810:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  800814:	89 f2                	mov    %esi,%edx
  800816:	89 f8                	mov    %edi,%eax
  800818:	e8 d3 fa ff ff       	call   8002f0 <printnum>
  80081d:	8b 5d cc             	mov    -0x34(%ebp),%ebx
			break;
  800820:	e9 44 fc ff ff       	jmp    800469 <vprintfmt+0x2c>
  800825:	89 45 cc             	mov    %eax,-0x34(%ebp)
  800828:	8b 55 e0             	mov    -0x20(%ebp),%edx

		// escaped '%' character
		case '%':
			putch(ch, putdat);
  80082b:	89 74 24 04          	mov    %esi,0x4(%esp)
  80082f:	89 14 24             	mov    %edx,(%esp)
  800832:	ff d7                	call   *%edi
  800834:	8b 5d cc             	mov    -0x34(%ebp),%ebx
			break;
  800837:	e9 2d fc ff ff       	jmp    800469 <vprintfmt+0x2c>
			
		// unrecognized escape sequence - just print it literally
		default:
			putch('%', putdat);
  80083c:	89 74 24 04          	mov    %esi,0x4(%esp)
  800840:	c7 04 24 25 00 00 00 	movl   $0x25,(%esp)
  800847:	ff d7                	call   *%edi
			for (fmt--; fmt[-1] != '%'; fmt--)
  800849:	8d 43 ff             	lea    -0x1(%ebx),%eax
  80084c:	80 38 25             	cmpb   $0x25,(%eax)
  80084f:	0f 84 14 fc ff ff    	je     800469 <vprintfmt+0x2c>
  800855:	89 c3                	mov    %eax,%ebx
  800857:	eb f0                	jmp    800849 <vprintfmt+0x40c>
				/* do nothing */;
			break;
		}
	}
}
  800859:	83 c4 5c             	add    $0x5c,%esp
  80085c:	5b                   	pop    %ebx
  80085d:	5e                   	pop    %esi
  80085e:	5f                   	pop    %edi
  80085f:	5d                   	pop    %ebp
  800860:	c3                   	ret    

00800861 <vsnprintf>:
		*b->buf++ = ch;
}

int
vsnprintf(char *buf, int n, const char *fmt, va_list ap)
{
  800861:	55                   	push   %ebp
  800862:	89 e5                	mov    %esp,%ebp
  800864:	83 ec 28             	sub    $0x28,%esp
  800867:	8b 45 08             	mov    0x8(%ebp),%eax
  80086a:	8b 55 0c             	mov    0xc(%ebp),%edx
	struct sprintbuf b = {buf, buf+n-1, 0};

	if (buf == NULL || n < 1)
  80086d:	85 c0                	test   %eax,%eax
  80086f:	74 04                	je     800875 <vsnprintf+0x14>
  800871:	85 d2                	test   %edx,%edx
  800873:	7f 07                	jg     80087c <vsnprintf+0x1b>
  800875:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
  80087a:	eb 3b                	jmp    8008b7 <vsnprintf+0x56>
}

int
vsnprintf(char *buf, int n, const char *fmt, va_list ap)
{
	struct sprintbuf b = {buf, buf+n-1, 0};
  80087c:	89 45 ec             	mov    %eax,-0x14(%ebp)
  80087f:	8d 44 10 ff          	lea    -0x1(%eax,%edx,1),%eax
  800883:	89 45 f0             	mov    %eax,-0x10(%ebp)
  800886:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)

	if (buf == NULL || n < 1)
		return -E_INVAL;

	// print the string to the buffer
	vprintfmt((void*)sprintputch, &b, fmt, ap);
  80088d:	8b 45 14             	mov    0x14(%ebp),%eax
  800890:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800894:	8b 45 10             	mov    0x10(%ebp),%eax
  800897:	89 44 24 08          	mov    %eax,0x8(%esp)
  80089b:	8d 45 ec             	lea    -0x14(%ebp),%eax
  80089e:	89 44 24 04          	mov    %eax,0x4(%esp)
  8008a2:	c7 04 24 20 04 80 00 	movl   $0x800420,(%esp)
  8008a9:	e8 8f fb ff ff       	call   80043d <vprintfmt>

	// null terminate the buffer
	*b.buf = '\0';
  8008ae:	8b 45 ec             	mov    -0x14(%ebp),%eax
  8008b1:	c6 00 00             	movb   $0x0,(%eax)

	return b.cnt;
  8008b4:	8b 45 f4             	mov    -0xc(%ebp),%eax
}
  8008b7:	c9                   	leave  
  8008b8:	c3                   	ret    

008008b9 <snprintf>:

int
snprintf(char *buf, int n, const char *fmt, ...)
{
  8008b9:	55                   	push   %ebp
  8008ba:	89 e5                	mov    %esp,%ebp
  8008bc:	83 ec 18             	sub    $0x18,%esp

	return b.cnt;
}

int
snprintf(char *buf, int n, const char *fmt, ...)
  8008bf:	8d 45 14             	lea    0x14(%ebp),%eax
{
	va_list ap;
	int rc;

	va_start(ap, fmt);
	rc = vsnprintf(buf, n, fmt, ap);
  8008c2:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8008c6:	8b 45 10             	mov    0x10(%ebp),%eax
  8008c9:	89 44 24 08          	mov    %eax,0x8(%esp)
  8008cd:	8b 45 0c             	mov    0xc(%ebp),%eax
  8008d0:	89 44 24 04          	mov    %eax,0x4(%esp)
  8008d4:	8b 45 08             	mov    0x8(%ebp),%eax
  8008d7:	89 04 24             	mov    %eax,(%esp)
  8008da:	e8 82 ff ff ff       	call   800861 <vsnprintf>
	va_end(ap);

	return rc;
}
  8008df:	c9                   	leave  
  8008e0:	c3                   	ret    

008008e1 <printfmt>:
	}
}

void
printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...)
{
  8008e1:	55                   	push   %ebp
  8008e2:	89 e5                	mov    %esp,%ebp
  8008e4:	83 ec 18             	sub    $0x18,%esp
		}
	}
}

void
printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...)
  8008e7:	8d 45 14             	lea    0x14(%ebp),%eax
{
	va_list ap;

	va_start(ap, fmt);
	vprintfmt(putch, putdat, fmt, ap);
  8008ea:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8008ee:	8b 45 10             	mov    0x10(%ebp),%eax
  8008f1:	89 44 24 08          	mov    %eax,0x8(%esp)
  8008f5:	8b 45 0c             	mov    0xc(%ebp),%eax
  8008f8:	89 44 24 04          	mov    %eax,0x4(%esp)
  8008fc:	8b 45 08             	mov    0x8(%ebp),%eax
  8008ff:	89 04 24             	mov    %eax,(%esp)
  800902:	e8 36 fb ff ff       	call   80043d <vprintfmt>
	va_end(ap);
}
  800907:	c9                   	leave  
  800908:	c3                   	ret    
  800909:	00 00                	add    %al,(%eax)
  80090b:	00 00                	add    %al,(%eax)
  80090d:	00 00                	add    %al,(%eax)
	...

00800910 <strlen>:
// Primespipe runs 3x faster this way.
#define ASM 1

int
strlen(const char *s)
{
  800910:	55                   	push   %ebp
  800911:	89 e5                	mov    %esp,%ebp
  800913:	8b 55 08             	mov    0x8(%ebp),%edx
	int n;

	for (n = 0; *s != '\0'; s++)
  800916:	b8 00 00 00 00       	mov    $0x0,%eax
  80091b:	80 3a 00             	cmpb   $0x0,(%edx)
  80091e:	74 09                	je     800929 <strlen+0x19>
		n++;
  800920:	83 c0 01             	add    $0x1,%eax
int
strlen(const char *s)
{
	int n;

	for (n = 0; *s != '\0'; s++)
  800923:	80 3c 02 00          	cmpb   $0x0,(%edx,%eax,1)
  800927:	75 f7                	jne    800920 <strlen+0x10>
		n++;
	return n;
}
  800929:	5d                   	pop    %ebp
  80092a:	c3                   	ret    

0080092b <strnlen>:

int
strnlen(const char *s, size_t size)
{
  80092b:	55                   	push   %ebp
  80092c:	89 e5                	mov    %esp,%ebp
  80092e:	53                   	push   %ebx
  80092f:	8b 5d 08             	mov    0x8(%ebp),%ebx
  800932:	8b 4d 0c             	mov    0xc(%ebp),%ecx
	int n;

	for (n = 0; size > 0 && *s != '\0'; s++, size--)
  800935:	85 c9                	test   %ecx,%ecx
  800937:	74 19                	je     800952 <strnlen+0x27>
  800939:	80 3b 00             	cmpb   $0x0,(%ebx)
  80093c:	74 14                	je     800952 <strnlen+0x27>
  80093e:	b8 00 00 00 00       	mov    $0x0,%eax
		n++;
  800943:	83 c0 01             	add    $0x1,%eax
int
strnlen(const char *s, size_t size)
{
	int n;

	for (n = 0; size > 0 && *s != '\0'; s++, size--)
  800946:	39 c8                	cmp    %ecx,%eax
  800948:	74 0d                	je     800957 <strnlen+0x2c>
  80094a:	80 3c 03 00          	cmpb   $0x0,(%ebx,%eax,1)
  80094e:	75 f3                	jne    800943 <strnlen+0x18>
  800950:	eb 05                	jmp    800957 <strnlen+0x2c>
  800952:	b8 00 00 00 00       	mov    $0x0,%eax
		n++;
	return n;
}
  800957:	5b                   	pop    %ebx
  800958:	5d                   	pop    %ebp
  800959:	c3                   	ret    

0080095a <strcpy>:

char *
strcpy(char *dst, const char *src)
{
  80095a:	55                   	push   %ebp
  80095b:	89 e5                	mov    %esp,%ebp
  80095d:	53                   	push   %ebx
  80095e:	8b 45 08             	mov    0x8(%ebp),%eax
  800961:	8b 5d 0c             	mov    0xc(%ebp),%ebx
  800964:	ba 00 00 00 00       	mov    $0x0,%edx
	char *ret;

	ret = dst;
	while ((*dst++ = *src++) != '\0')
  800969:	0f b6 0c 13          	movzbl (%ebx,%edx,1),%ecx
  80096d:	88 0c 10             	mov    %cl,(%eax,%edx,1)
  800970:	83 c2 01             	add    $0x1,%edx
  800973:	84 c9                	test   %cl,%cl
  800975:	75 f2                	jne    800969 <strcpy+0xf>
		/* do nothing */;
	return ret;
}
  800977:	5b                   	pop    %ebx
  800978:	5d                   	pop    %ebp
  800979:	c3                   	ret    

0080097a <strncpy>:

char *
strncpy(char *dst, const char *src, size_t size) {
  80097a:	55                   	push   %ebp
  80097b:	89 e5                	mov    %esp,%ebp
  80097d:	56                   	push   %esi
  80097e:	53                   	push   %ebx
  80097f:	8b 45 08             	mov    0x8(%ebp),%eax
  800982:	8b 55 0c             	mov    0xc(%ebp),%edx
  800985:	8b 75 10             	mov    0x10(%ebp),%esi
	size_t i;
	char *ret;

	ret = dst;
	for (i = 0; i < size; i++) {
  800988:	85 f6                	test   %esi,%esi
  80098a:	74 18                	je     8009a4 <strncpy+0x2a>
  80098c:	b9 00 00 00 00       	mov    $0x0,%ecx
		*dst++ = *src;
  800991:	0f b6 1a             	movzbl (%edx),%ebx
  800994:	88 1c 08             	mov    %bl,(%eax,%ecx,1)
		// If strlen(src) < size, null-pad 'dst' out to 'size' chars
		if (*src != '\0')
			src++;
  800997:	80 3a 01             	cmpb   $0x1,(%edx)
  80099a:	83 da ff             	sbb    $0xffffffff,%edx
strncpy(char *dst, const char *src, size_t size) {
	size_t i;
	char *ret;

	ret = dst;
	for (i = 0; i < size; i++) {
  80099d:	83 c1 01             	add    $0x1,%ecx
  8009a0:	39 ce                	cmp    %ecx,%esi
  8009a2:	77 ed                	ja     800991 <strncpy+0x17>
		// If strlen(src) < size, null-pad 'dst' out to 'size' chars
		if (*src != '\0')
			src++;
	}
	return ret;
}
  8009a4:	5b                   	pop    %ebx
  8009a5:	5e                   	pop    %esi
  8009a6:	5d                   	pop    %ebp
  8009a7:	c3                   	ret    

008009a8 <strlcpy>:

size_t
strlcpy(char *dst, const char *src, size_t size)
{
  8009a8:	55                   	push   %ebp
  8009a9:	89 e5                	mov    %esp,%ebp
  8009ab:	56                   	push   %esi
  8009ac:	53                   	push   %ebx
  8009ad:	8b 75 08             	mov    0x8(%ebp),%esi
  8009b0:	8b 55 0c             	mov    0xc(%ebp),%edx
  8009b3:	8b 4d 10             	mov    0x10(%ebp),%ecx
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
  8009b6:	89 f0                	mov    %esi,%eax
  8009b8:	85 c9                	test   %ecx,%ecx
  8009ba:	74 27                	je     8009e3 <strlcpy+0x3b>
		while (--size > 0 && *src != '\0')
  8009bc:	83 e9 01             	sub    $0x1,%ecx
  8009bf:	74 1d                	je     8009de <strlcpy+0x36>
  8009c1:	0f b6 1a             	movzbl (%edx),%ebx
  8009c4:	84 db                	test   %bl,%bl
  8009c6:	74 16                	je     8009de <strlcpy+0x36>
			*dst++ = *src++;
  8009c8:	88 18                	mov    %bl,(%eax)
  8009ca:	83 c0 01             	add    $0x1,%eax
{
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
		while (--size > 0 && *src != '\0')
  8009cd:	83 e9 01             	sub    $0x1,%ecx
  8009d0:	74 0e                	je     8009e0 <strlcpy+0x38>
			*dst++ = *src++;
  8009d2:	83 c2 01             	add    $0x1,%edx
{
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
		while (--size > 0 && *src != '\0')
  8009d5:	0f b6 1a             	movzbl (%edx),%ebx
  8009d8:	84 db                	test   %bl,%bl
  8009da:	75 ec                	jne    8009c8 <strlcpy+0x20>
  8009dc:	eb 02                	jmp    8009e0 <strlcpy+0x38>
  8009de:	89 f0                	mov    %esi,%eax
			*dst++ = *src++;
		*dst = '\0';
  8009e0:	c6 00 00             	movb   $0x0,(%eax)
  8009e3:	29 f0                	sub    %esi,%eax
	}
	return dst - dst_in;
}
  8009e5:	5b                   	pop    %ebx
  8009e6:	5e                   	pop    %esi
  8009e7:	5d                   	pop    %ebp
  8009e8:	c3                   	ret    

008009e9 <strcmp>:

int
strcmp(const char *p, const char *q)
{
  8009e9:	55                   	push   %ebp
  8009ea:	89 e5                	mov    %esp,%ebp
  8009ec:	8b 4d 08             	mov    0x8(%ebp),%ecx
  8009ef:	8b 55 0c             	mov    0xc(%ebp),%edx
	while (*p && *p == *q)
  8009f2:	0f b6 01             	movzbl (%ecx),%eax
  8009f5:	84 c0                	test   %al,%al
  8009f7:	74 15                	je     800a0e <strcmp+0x25>
  8009f9:	3a 02                	cmp    (%edx),%al
  8009fb:	75 11                	jne    800a0e <strcmp+0x25>
		p++, q++;
  8009fd:	83 c1 01             	add    $0x1,%ecx
  800a00:	83 c2 01             	add    $0x1,%edx
}

int
strcmp(const char *p, const char *q)
{
	while (*p && *p == *q)
  800a03:	0f b6 01             	movzbl (%ecx),%eax
  800a06:	84 c0                	test   %al,%al
  800a08:	74 04                	je     800a0e <strcmp+0x25>
  800a0a:	3a 02                	cmp    (%edx),%al
  800a0c:	74 ef                	je     8009fd <strcmp+0x14>
  800a0e:	0f b6 c0             	movzbl %al,%eax
  800a11:	0f b6 12             	movzbl (%edx),%edx
  800a14:	29 d0                	sub    %edx,%eax
		p++, q++;
	return (int) ((unsigned char) *p - (unsigned char) *q);
}
  800a16:	5d                   	pop    %ebp
  800a17:	c3                   	ret    

00800a18 <strncmp>:

int
strncmp(const char *p, const char *q, size_t n)
{
  800a18:	55                   	push   %ebp
  800a19:	89 e5                	mov    %esp,%ebp
  800a1b:	53                   	push   %ebx
  800a1c:	8b 55 08             	mov    0x8(%ebp),%edx
  800a1f:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800a22:	8b 45 10             	mov    0x10(%ebp),%eax
	while (n > 0 && *p && *p == *q)
  800a25:	85 c0                	test   %eax,%eax
  800a27:	74 23                	je     800a4c <strncmp+0x34>
  800a29:	0f b6 1a             	movzbl (%edx),%ebx
  800a2c:	84 db                	test   %bl,%bl
  800a2e:	74 24                	je     800a54 <strncmp+0x3c>
  800a30:	3a 19                	cmp    (%ecx),%bl
  800a32:	75 20                	jne    800a54 <strncmp+0x3c>
  800a34:	83 e8 01             	sub    $0x1,%eax
  800a37:	74 13                	je     800a4c <strncmp+0x34>
		n--, p++, q++;
  800a39:	83 c2 01             	add    $0x1,%edx
  800a3c:	83 c1 01             	add    $0x1,%ecx
}

int
strncmp(const char *p, const char *q, size_t n)
{
	while (n > 0 && *p && *p == *q)
  800a3f:	0f b6 1a             	movzbl (%edx),%ebx
  800a42:	84 db                	test   %bl,%bl
  800a44:	74 0e                	je     800a54 <strncmp+0x3c>
  800a46:	3a 19                	cmp    (%ecx),%bl
  800a48:	74 ea                	je     800a34 <strncmp+0x1c>
  800a4a:	eb 08                	jmp    800a54 <strncmp+0x3c>
  800a4c:	b8 00 00 00 00       	mov    $0x0,%eax
		n--, p++, q++;
	if (n == 0)
		return 0;
	else
		return (int) ((unsigned char) *p - (unsigned char) *q);
}
  800a51:	5b                   	pop    %ebx
  800a52:	5d                   	pop    %ebp
  800a53:	c3                   	ret    
	while (n > 0 && *p && *p == *q)
		n--, p++, q++;
	if (n == 0)
		return 0;
	else
		return (int) ((unsigned char) *p - (unsigned char) *q);
  800a54:	0f b6 02             	movzbl (%edx),%eax
  800a57:	0f b6 11             	movzbl (%ecx),%edx
  800a5a:	29 d0                	sub    %edx,%eax
  800a5c:	eb f3                	jmp    800a51 <strncmp+0x39>

00800a5e <strchr>:

// Return a pointer to the first occurrence of 'c' in 's',
// or a null pointer if the string has no 'c'.
char *
strchr(const char *s, char c)
{
  800a5e:	55                   	push   %ebp
  800a5f:	89 e5                	mov    %esp,%ebp
  800a61:	8b 45 08             	mov    0x8(%ebp),%eax
  800a64:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
	for (; *s; s++)
  800a68:	0f b6 10             	movzbl (%eax),%edx
  800a6b:	84 d2                	test   %dl,%dl
  800a6d:	74 15                	je     800a84 <strchr+0x26>
		if (*s == c)
  800a6f:	38 ca                	cmp    %cl,%dl
  800a71:	75 07                	jne    800a7a <strchr+0x1c>
  800a73:	eb 14                	jmp    800a89 <strchr+0x2b>
  800a75:	38 ca                	cmp    %cl,%dl
  800a77:	90                   	nop
  800a78:	74 0f                	je     800a89 <strchr+0x2b>
// Return a pointer to the first occurrence of 'c' in 's',
// or a null pointer if the string has no 'c'.
char *
strchr(const char *s, char c)
{
	for (; *s; s++)
  800a7a:	83 c0 01             	add    $0x1,%eax
  800a7d:	0f b6 10             	movzbl (%eax),%edx
  800a80:	84 d2                	test   %dl,%dl
  800a82:	75 f1                	jne    800a75 <strchr+0x17>
  800a84:	b8 00 00 00 00       	mov    $0x0,%eax
		if (*s == c)
			return (char *) s;
	return 0;
}
  800a89:	5d                   	pop    %ebp
  800a8a:	c3                   	ret    

00800a8b <strfind>:

// Return a pointer to the first occurrence of 'c' in 's',
// or a pointer to the string-ending null character if the string has no 'c'.
char *
strfind(const char *s, char c)
{
  800a8b:	55                   	push   %ebp
  800a8c:	89 e5                	mov    %esp,%ebp
  800a8e:	8b 45 08             	mov    0x8(%ebp),%eax
  800a91:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
	for (; *s; s++)
  800a95:	0f b6 10             	movzbl (%eax),%edx
  800a98:	84 d2                	test   %dl,%dl
  800a9a:	74 18                	je     800ab4 <strfind+0x29>
		if (*s == c)
  800a9c:	38 ca                	cmp    %cl,%dl
  800a9e:	75 0a                	jne    800aaa <strfind+0x1f>
  800aa0:	eb 12                	jmp    800ab4 <strfind+0x29>
  800aa2:	38 ca                	cmp    %cl,%dl
  800aa4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  800aa8:	74 0a                	je     800ab4 <strfind+0x29>
// Return a pointer to the first occurrence of 'c' in 's',
// or a pointer to the string-ending null character if the string has no 'c'.
char *
strfind(const char *s, char c)
{
	for (; *s; s++)
  800aaa:	83 c0 01             	add    $0x1,%eax
  800aad:	0f b6 10             	movzbl (%eax),%edx
  800ab0:	84 d2                	test   %dl,%dl
  800ab2:	75 ee                	jne    800aa2 <strfind+0x17>
		if (*s == c)
			break;
	return (char *) s;
}
  800ab4:	5d                   	pop    %ebp
  800ab5:	c3                   	ret    

00800ab6 <memset>:

#if ASM
void *
memset(void *v, int c, size_t n)
{
  800ab6:	55                   	push   %ebp
  800ab7:	89 e5                	mov    %esp,%ebp
  800ab9:	83 ec 0c             	sub    $0xc,%esp
  800abc:	89 1c 24             	mov    %ebx,(%esp)
  800abf:	89 74 24 04          	mov    %esi,0x4(%esp)
  800ac3:	89 7c 24 08          	mov    %edi,0x8(%esp)
  800ac7:	8b 7d 08             	mov    0x8(%ebp),%edi
  800aca:	8b 45 0c             	mov    0xc(%ebp),%eax
  800acd:	8b 4d 10             	mov    0x10(%ebp),%ecx
	char *p;

	if (n == 0)
  800ad0:	85 c9                	test   %ecx,%ecx
  800ad2:	74 30                	je     800b04 <memset+0x4e>
		return v;
	if ((int)v%4 == 0 && n%4 == 0) {
  800ad4:	f7 c7 03 00 00 00    	test   $0x3,%edi
  800ada:	75 25                	jne    800b01 <memset+0x4b>
  800adc:	f6 c1 03             	test   $0x3,%cl
  800adf:	75 20                	jne    800b01 <memset+0x4b>
		c &= 0xFF;
  800ae1:	0f b6 d0             	movzbl %al,%edx
		c = (c<<24)|(c<<16)|(c<<8)|c;
  800ae4:	89 d3                	mov    %edx,%ebx
  800ae6:	c1 e3 08             	shl    $0x8,%ebx
  800ae9:	89 d6                	mov    %edx,%esi
  800aeb:	c1 e6 18             	shl    $0x18,%esi
  800aee:	89 d0                	mov    %edx,%eax
  800af0:	c1 e0 10             	shl    $0x10,%eax
  800af3:	09 f0                	or     %esi,%eax
  800af5:	09 d0                	or     %edx,%eax
		asm volatile("cld; rep stosl\n"
  800af7:	09 d8                	or     %ebx,%eax
  800af9:	c1 e9 02             	shr    $0x2,%ecx
  800afc:	fc                   	cld    
  800afd:	f3 ab                	rep stos %eax,%es:(%edi)
{
	char *p;

	if (n == 0)
		return v;
	if ((int)v%4 == 0 && n%4 == 0) {
  800aff:	eb 03                	jmp    800b04 <memset+0x4e>
		c = (c<<24)|(c<<16)|(c<<8)|c;
		asm volatile("cld; rep stosl\n"
			:: "D" (v), "a" (c), "c" (n/4)
			: "cc", "memory");
	} else
		asm volatile("cld; rep stosb\n"
  800b01:	fc                   	cld    
  800b02:	f3 aa                	rep stos %al,%es:(%edi)
			:: "D" (v), "a" (c), "c" (n)
			: "cc", "memory");
	return v;
}
  800b04:	89 f8                	mov    %edi,%eax
  800b06:	8b 1c 24             	mov    (%esp),%ebx
  800b09:	8b 74 24 04          	mov    0x4(%esp),%esi
  800b0d:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800b11:	89 ec                	mov    %ebp,%esp
  800b13:	5d                   	pop    %ebp
  800b14:	c3                   	ret    

00800b15 <memmove>:

void *
memmove(void *dst, const void *src, size_t n)
{
  800b15:	55                   	push   %ebp
  800b16:	89 e5                	mov    %esp,%ebp
  800b18:	83 ec 08             	sub    $0x8,%esp
  800b1b:	89 34 24             	mov    %esi,(%esp)
  800b1e:	89 7c 24 04          	mov    %edi,0x4(%esp)
  800b22:	8b 45 08             	mov    0x8(%ebp),%eax
  800b25:	8b 4d 10             	mov    0x10(%ebp),%ecx
	const char *s;
	char *d;
	
	s = src;
  800b28:	8b 75 0c             	mov    0xc(%ebp),%esi
	d = dst;
  800b2b:	89 c7                	mov    %eax,%edi
	if (s < d && s + n > d) {
  800b2d:	39 c6                	cmp    %eax,%esi
  800b2f:	73 35                	jae    800b66 <memmove+0x51>
  800b31:	8d 14 0e             	lea    (%esi,%ecx,1),%edx
  800b34:	39 d0                	cmp    %edx,%eax
  800b36:	73 2e                	jae    800b66 <memmove+0x51>
		s += n;
		d += n;
  800b38:	01 cf                	add    %ecx,%edi
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800b3a:	f6 c2 03             	test   $0x3,%dl
  800b3d:	75 1b                	jne    800b5a <memmove+0x45>
  800b3f:	f7 c7 03 00 00 00    	test   $0x3,%edi
  800b45:	75 13                	jne    800b5a <memmove+0x45>
  800b47:	f6 c1 03             	test   $0x3,%cl
  800b4a:	75 0e                	jne    800b5a <memmove+0x45>
			asm volatile("std; rep movsl\n"
  800b4c:	83 ef 04             	sub    $0x4,%edi
  800b4f:	8d 72 fc             	lea    -0x4(%edx),%esi
  800b52:	c1 e9 02             	shr    $0x2,%ecx
  800b55:	fd                   	std    
  800b56:	f3 a5                	rep movsl %ds:(%esi),%es:(%edi)
	s = src;
	d = dst;
	if (s < d && s + n > d) {
		s += n;
		d += n;
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800b58:	eb 09                	jmp    800b63 <memmove+0x4e>
			asm volatile("std; rep movsl\n"
				:: "D" (d-4), "S" (s-4), "c" (n/4) : "cc", "memory");
		else
			asm volatile("std; rep movsb\n"
  800b5a:	83 ef 01             	sub    $0x1,%edi
  800b5d:	8d 72 ff             	lea    -0x1(%edx),%esi
  800b60:	fd                   	std    
  800b61:	f3 a4                	rep movsb %ds:(%esi),%es:(%edi)
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
  800b63:	fc                   	cld    
	const char *s;
	char *d;
	
	s = src;
	d = dst;
	if (s < d && s + n > d) {
  800b64:	eb 20                	jmp    800b86 <memmove+0x71>
			asm volatile("std; rep movsb\n"
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
	} else {
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800b66:	f7 c6 03 00 00 00    	test   $0x3,%esi
  800b6c:	75 15                	jne    800b83 <memmove+0x6e>
  800b6e:	f7 c7 03 00 00 00    	test   $0x3,%edi
  800b74:	75 0d                	jne    800b83 <memmove+0x6e>
  800b76:	f6 c1 03             	test   $0x3,%cl
  800b79:	75 08                	jne    800b83 <memmove+0x6e>
			asm volatile("cld; rep movsl\n"
  800b7b:	c1 e9 02             	shr    $0x2,%ecx
  800b7e:	fc                   	cld    
  800b7f:	f3 a5                	rep movsl %ds:(%esi),%es:(%edi)
			asm volatile("std; rep movsb\n"
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
	} else {
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800b81:	eb 03                	jmp    800b86 <memmove+0x71>
			asm volatile("cld; rep movsl\n"
				:: "D" (d), "S" (s), "c" (n/4) : "cc", "memory");
		else
			asm volatile("cld; rep movsb\n"
  800b83:	fc                   	cld    
  800b84:	f3 a4                	rep movsb %ds:(%esi),%es:(%edi)
				:: "D" (d), "S" (s), "c" (n) : "cc", "memory");
	}
	return dst;
}
  800b86:	8b 34 24             	mov    (%esp),%esi
  800b89:	8b 7c 24 04          	mov    0x4(%esp),%edi
  800b8d:	89 ec                	mov    %ebp,%esp
  800b8f:	5d                   	pop    %ebp
  800b90:	c3                   	ret    

00800b91 <memcpy>:

/* sigh - gcc emits references to this for structure assignments! */
/* it is *not* prototyped in inc/string.h - do not use directly. */
void *
memcpy(void *dst, void *src, size_t n)
{
  800b91:	55                   	push   %ebp
  800b92:	89 e5                	mov    %esp,%ebp
  800b94:	83 ec 0c             	sub    $0xc,%esp
	return memmove(dst, src, n);
  800b97:	8b 45 10             	mov    0x10(%ebp),%eax
  800b9a:	89 44 24 08          	mov    %eax,0x8(%esp)
  800b9e:	8b 45 0c             	mov    0xc(%ebp),%eax
  800ba1:	89 44 24 04          	mov    %eax,0x4(%esp)
  800ba5:	8b 45 08             	mov    0x8(%ebp),%eax
  800ba8:	89 04 24             	mov    %eax,(%esp)
  800bab:	e8 65 ff ff ff       	call   800b15 <memmove>
}
  800bb0:	c9                   	leave  
  800bb1:	c3                   	ret    

00800bb2 <memcmp>:

int
memcmp(const void *v1, const void *v2, size_t n)
{
  800bb2:	55                   	push   %ebp
  800bb3:	89 e5                	mov    %esp,%ebp
  800bb5:	57                   	push   %edi
  800bb6:	56                   	push   %esi
  800bb7:	53                   	push   %ebx
  800bb8:	8b 75 08             	mov    0x8(%ebp),%esi
  800bbb:	8b 7d 0c             	mov    0xc(%ebp),%edi
  800bbe:	8b 4d 10             	mov    0x10(%ebp),%ecx
	const uint8_t *s1 = (const uint8_t *) v1;
	const uint8_t *s2 = (const uint8_t *) v2;

	while (n-- > 0) {
  800bc1:	85 c9                	test   %ecx,%ecx
  800bc3:	74 36                	je     800bfb <memcmp+0x49>
		if (*s1 != *s2)
  800bc5:	0f b6 06             	movzbl (%esi),%eax
  800bc8:	0f b6 1f             	movzbl (%edi),%ebx
  800bcb:	38 d8                	cmp    %bl,%al
  800bcd:	74 20                	je     800bef <memcmp+0x3d>
  800bcf:	eb 14                	jmp    800be5 <memcmp+0x33>
  800bd1:	0f b6 44 16 01       	movzbl 0x1(%esi,%edx,1),%eax
  800bd6:	0f b6 5c 17 01       	movzbl 0x1(%edi,%edx,1),%ebx
  800bdb:	83 c2 01             	add    $0x1,%edx
  800bde:	83 e9 01             	sub    $0x1,%ecx
  800be1:	38 d8                	cmp    %bl,%al
  800be3:	74 12                	je     800bf7 <memcmp+0x45>
			return (int) *s1 - (int) *s2;
  800be5:	0f b6 c0             	movzbl %al,%eax
  800be8:	0f b6 db             	movzbl %bl,%ebx
  800beb:	29 d8                	sub    %ebx,%eax
  800bed:	eb 11                	jmp    800c00 <memcmp+0x4e>
memcmp(const void *v1, const void *v2, size_t n)
{
	const uint8_t *s1 = (const uint8_t *) v1;
	const uint8_t *s2 = (const uint8_t *) v2;

	while (n-- > 0) {
  800bef:	83 e9 01             	sub    $0x1,%ecx
  800bf2:	ba 00 00 00 00       	mov    $0x0,%edx
  800bf7:	85 c9                	test   %ecx,%ecx
  800bf9:	75 d6                	jne    800bd1 <memcmp+0x1f>
  800bfb:	b8 00 00 00 00       	mov    $0x0,%eax
			return (int) *s1 - (int) *s2;
		s1++, s2++;
	}

	return 0;
}
  800c00:	5b                   	pop    %ebx
  800c01:	5e                   	pop    %esi
  800c02:	5f                   	pop    %edi
  800c03:	5d                   	pop    %ebp
  800c04:	c3                   	ret    

00800c05 <memfind>:

void *
memfind(const void *s, int c, size_t n)
{
  800c05:	55                   	push   %ebp
  800c06:	89 e5                	mov    %esp,%ebp
  800c08:	8b 45 08             	mov    0x8(%ebp),%eax
	const void *ends = (const char *) s + n;
  800c0b:	89 c2                	mov    %eax,%edx
  800c0d:	03 55 10             	add    0x10(%ebp),%edx
	for (; s < ends; s++)
  800c10:	39 d0                	cmp    %edx,%eax
  800c12:	73 15                	jae    800c29 <memfind+0x24>
		if (*(const unsigned char *) s == (unsigned char) c)
  800c14:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
  800c18:	38 08                	cmp    %cl,(%eax)
  800c1a:	75 06                	jne    800c22 <memfind+0x1d>
  800c1c:	eb 0b                	jmp    800c29 <memfind+0x24>
  800c1e:	38 08                	cmp    %cl,(%eax)
  800c20:	74 07                	je     800c29 <memfind+0x24>

void *
memfind(const void *s, int c, size_t n)
{
	const void *ends = (const char *) s + n;
	for (; s < ends; s++)
  800c22:	83 c0 01             	add    $0x1,%eax
  800c25:	39 c2                	cmp    %eax,%edx
  800c27:	77 f5                	ja     800c1e <memfind+0x19>
		if (*(const unsigned char *) s == (unsigned char) c)
			break;
	return (void *) s;
}
  800c29:	5d                   	pop    %ebp
  800c2a:	c3                   	ret    

00800c2b <strtol>:

long
strtol(const char *s, char **endptr, int base)
{
  800c2b:	55                   	push   %ebp
  800c2c:	89 e5                	mov    %esp,%ebp
  800c2e:	57                   	push   %edi
  800c2f:	56                   	push   %esi
  800c30:	53                   	push   %ebx
  800c31:	83 ec 04             	sub    $0x4,%esp
  800c34:	8b 55 08             	mov    0x8(%ebp),%edx
  800c37:	8b 5d 10             	mov    0x10(%ebp),%ebx
	int neg = 0;
	long val = 0;

	// gobble initial whitespace
	while (*s == ' ' || *s == '\t')
  800c3a:	0f b6 02             	movzbl (%edx),%eax
  800c3d:	3c 20                	cmp    $0x20,%al
  800c3f:	74 04                	je     800c45 <strtol+0x1a>
  800c41:	3c 09                	cmp    $0x9,%al
  800c43:	75 0e                	jne    800c53 <strtol+0x28>
		s++;
  800c45:	83 c2 01             	add    $0x1,%edx
{
	int neg = 0;
	long val = 0;

	// gobble initial whitespace
	while (*s == ' ' || *s == '\t')
  800c48:	0f b6 02             	movzbl (%edx),%eax
  800c4b:	3c 20                	cmp    $0x20,%al
  800c4d:	74 f6                	je     800c45 <strtol+0x1a>
  800c4f:	3c 09                	cmp    $0x9,%al
  800c51:	74 f2                	je     800c45 <strtol+0x1a>
		s++;

	// plus/minus sign
	if (*s == '+')
  800c53:	3c 2b                	cmp    $0x2b,%al
  800c55:	75 0c                	jne    800c63 <strtol+0x38>
		s++;
  800c57:	83 c2 01             	add    $0x1,%edx
  800c5a:	c7 45 f0 00 00 00 00 	movl   $0x0,-0x10(%ebp)
  800c61:	eb 15                	jmp    800c78 <strtol+0x4d>
	else if (*s == '-')
  800c63:	c7 45 f0 00 00 00 00 	movl   $0x0,-0x10(%ebp)
  800c6a:	3c 2d                	cmp    $0x2d,%al
  800c6c:	75 0a                	jne    800c78 <strtol+0x4d>
		s++, neg = 1;
  800c6e:	83 c2 01             	add    $0x1,%edx
  800c71:	c7 45 f0 01 00 00 00 	movl   $0x1,-0x10(%ebp)

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
  800c78:	85 db                	test   %ebx,%ebx
  800c7a:	0f 94 c0             	sete   %al
  800c7d:	74 05                	je     800c84 <strtol+0x59>
  800c7f:	83 fb 10             	cmp    $0x10,%ebx
  800c82:	75 18                	jne    800c9c <strtol+0x71>
  800c84:	80 3a 30             	cmpb   $0x30,(%edx)
  800c87:	75 13                	jne    800c9c <strtol+0x71>
  800c89:	80 7a 01 78          	cmpb   $0x78,0x1(%edx)
  800c8d:	8d 76 00             	lea    0x0(%esi),%esi
  800c90:	75 0a                	jne    800c9c <strtol+0x71>
		s += 2, base = 16;
  800c92:	83 c2 02             	add    $0x2,%edx
  800c95:	bb 10 00 00 00       	mov    $0x10,%ebx
		s++;
	else if (*s == '-')
		s++, neg = 1;

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
  800c9a:	eb 15                	jmp    800cb1 <strtol+0x86>
		s += 2, base = 16;
	else if (base == 0 && s[0] == '0')
  800c9c:	84 c0                	test   %al,%al
  800c9e:	66 90                	xchg   %ax,%ax
  800ca0:	74 0f                	je     800cb1 <strtol+0x86>
  800ca2:	bb 0a 00 00 00       	mov    $0xa,%ebx
  800ca7:	80 3a 30             	cmpb   $0x30,(%edx)
  800caa:	75 05                	jne    800cb1 <strtol+0x86>
		s++, base = 8;
  800cac:	83 c2 01             	add    $0x1,%edx
  800caf:	b3 08                	mov    $0x8,%bl
		s++, neg = 1;

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
		s += 2, base = 16;
	else if (base == 0 && s[0] == '0')
  800cb1:	b8 00 00 00 00       	mov    $0x0,%eax
  800cb6:	89 de                	mov    %ebx,%esi

	// digits
	while (1) {
		int dig;

		if (*s >= '0' && *s <= '9')
  800cb8:	0f b6 0a             	movzbl (%edx),%ecx
  800cbb:	89 cf                	mov    %ecx,%edi
  800cbd:	8d 59 d0             	lea    -0x30(%ecx),%ebx
  800cc0:	80 fb 09             	cmp    $0x9,%bl
  800cc3:	77 08                	ja     800ccd <strtol+0xa2>
			dig = *s - '0';
  800cc5:	0f be c9             	movsbl %cl,%ecx
  800cc8:	83 e9 30             	sub    $0x30,%ecx
  800ccb:	eb 1e                	jmp    800ceb <strtol+0xc0>
		else if (*s >= 'a' && *s <= 'z')
  800ccd:	8d 5f 9f             	lea    -0x61(%edi),%ebx
  800cd0:	80 fb 19             	cmp    $0x19,%bl
  800cd3:	77 08                	ja     800cdd <strtol+0xb2>
			dig = *s - 'a' + 10;
  800cd5:	0f be c9             	movsbl %cl,%ecx
  800cd8:	83 e9 57             	sub    $0x57,%ecx
  800cdb:	eb 0e                	jmp    800ceb <strtol+0xc0>
		else if (*s >= 'A' && *s <= 'Z')
  800cdd:	8d 5f bf             	lea    -0x41(%edi),%ebx
  800ce0:	80 fb 19             	cmp    $0x19,%bl
  800ce3:	77 15                	ja     800cfa <strtol+0xcf>
			dig = *s - 'A' + 10;
  800ce5:	0f be c9             	movsbl %cl,%ecx
  800ce8:	83 e9 37             	sub    $0x37,%ecx
		else
			break;
		if (dig >= base)
  800ceb:	39 f1                	cmp    %esi,%ecx
  800ced:	7d 0b                	jge    800cfa <strtol+0xcf>
			break;
		s++, val = (val * base) + dig;
  800cef:	83 c2 01             	add    $0x1,%edx
  800cf2:	0f af c6             	imul   %esi,%eax
  800cf5:	8d 04 01             	lea    (%ecx,%eax,1),%eax
		// we don't properly detect overflow!
	}
  800cf8:	eb be                	jmp    800cb8 <strtol+0x8d>
  800cfa:	89 c1                	mov    %eax,%ecx

	if (endptr)
  800cfc:	83 7d 0c 00          	cmpl   $0x0,0xc(%ebp)
  800d00:	74 05                	je     800d07 <strtol+0xdc>
		*endptr = (char *) s;
  800d02:	8b 5d 0c             	mov    0xc(%ebp),%ebx
  800d05:	89 13                	mov    %edx,(%ebx)
	return (neg ? -val : val);
  800d07:	89 ca                	mov    %ecx,%edx
  800d09:	f7 da                	neg    %edx
  800d0b:	83 7d f0 00          	cmpl   $0x0,-0x10(%ebp)
  800d0f:	0f 45 c2             	cmovne %edx,%eax
}
  800d12:	83 c4 04             	add    $0x4,%esp
  800d15:	5b                   	pop    %ebx
  800d16:	5e                   	pop    %esi
  800d17:	5f                   	pop    %edi
  800d18:	5d                   	pop    %ebp
  800d19:	c3                   	ret    
	...

00800d1c <sys_cgetc>:
	syscall(SYS_cputs, 0, (uint32_t)s, len, 0, 0, 0);
}

int
sys_cgetc(void)
{
  800d1c:	55                   	push   %ebp
  800d1d:	89 e5                	mov    %esp,%ebp
  800d1f:	83 ec 0c             	sub    $0xc,%esp
  800d22:	89 1c 24             	mov    %ebx,(%esp)
  800d25:	89 74 24 04          	mov    %esi,0x4(%esp)
  800d29:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800d2d:	ba 00 00 00 00       	mov    $0x0,%edx
  800d32:	b8 01 00 00 00       	mov    $0x1,%eax
  800d37:	89 d1                	mov    %edx,%ecx
  800d39:	89 d3                	mov    %edx,%ebx
  800d3b:	89 d7                	mov    %edx,%edi
  800d3d:	89 d6                	mov    %edx,%esi
  800d3f:	cd 30                	int    $0x30

int
sys_cgetc(void)
{
	return syscall(SYS_cgetc, 0, 0, 0, 0, 0, 0);
}
  800d41:	8b 1c 24             	mov    (%esp),%ebx
  800d44:	8b 74 24 04          	mov    0x4(%esp),%esi
  800d48:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800d4c:	89 ec                	mov    %ebp,%esp
  800d4e:	5d                   	pop    %ebp
  800d4f:	c3                   	ret    

00800d50 <sys_cputs>:
	return ret;
}

void
sys_cputs(const char *s, size_t len)
{
  800d50:	55                   	push   %ebp
  800d51:	89 e5                	mov    %esp,%ebp
  800d53:	83 ec 0c             	sub    $0xc,%esp
  800d56:	89 1c 24             	mov    %ebx,(%esp)
  800d59:	89 74 24 04          	mov    %esi,0x4(%esp)
  800d5d:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800d61:	b8 00 00 00 00       	mov    $0x0,%eax
  800d66:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800d69:	8b 55 08             	mov    0x8(%ebp),%edx
  800d6c:	89 c3                	mov    %eax,%ebx
  800d6e:	89 c7                	mov    %eax,%edi
  800d70:	89 c6                	mov    %eax,%esi
  800d72:	cd 30                	int    $0x30

void
sys_cputs(const char *s, size_t len)
{
	syscall(SYS_cputs, 0, (uint32_t)s, len, 0, 0, 0);
}
  800d74:	8b 1c 24             	mov    (%esp),%ebx
  800d77:	8b 74 24 04          	mov    0x4(%esp),%esi
  800d7b:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800d7f:	89 ec                	mov    %ebp,%esp
  800d81:	5d                   	pop    %ebp
  800d82:	c3                   	ret    

00800d83 <sys_ns_recv>:
  return syscall(SYS_ns_send, 0, (uint32_t)pkt, len, 0, 0, 0);
}

int
sys_ns_recv(void *pkt, uint32_t len)
{
  800d83:	55                   	push   %ebp
  800d84:	89 e5                	mov    %esp,%ebp
  800d86:	83 ec 0c             	sub    $0xc,%esp
  800d89:	89 1c 24             	mov    %ebx,(%esp)
  800d8c:	89 74 24 04          	mov    %esi,0x4(%esp)
  800d90:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800d94:	bb 00 00 00 00       	mov    $0x0,%ebx
  800d99:	b8 10 00 00 00       	mov    $0x10,%eax
  800d9e:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800da1:	8b 55 08             	mov    0x8(%ebp),%edx
  800da4:	89 df                	mov    %ebx,%edi
  800da6:	89 de                	mov    %ebx,%esi
  800da8:	cd 30                	int    $0x30

int
sys_ns_recv(void *pkt, uint32_t len)
{
  return syscall(SYS_ns_recv, 0, (uint32_t)pkt, len, 0, 0, 0);
}
  800daa:	8b 1c 24             	mov    (%esp),%ebx
  800dad:	8b 74 24 04          	mov    0x4(%esp),%esi
  800db1:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800db5:	89 ec                	mov    %ebp,%esp
  800db7:	5d                   	pop    %ebp
  800db8:	c3                   	ret    

00800db9 <sys_ns_send>:
	return (unsigned int) syscall(SYS_time_msec, 0, 0, 0, 0, 0, 0);
}

int
sys_ns_send(void *pkt, uint32_t len)
{
  800db9:	55                   	push   %ebp
  800dba:	89 e5                	mov    %esp,%ebp
  800dbc:	83 ec 0c             	sub    $0xc,%esp
  800dbf:	89 1c 24             	mov    %ebx,(%esp)
  800dc2:	89 74 24 04          	mov    %esi,0x4(%esp)
  800dc6:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800dca:	bb 00 00 00 00       	mov    $0x0,%ebx
  800dcf:	b8 0f 00 00 00       	mov    $0xf,%eax
  800dd4:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800dd7:	8b 55 08             	mov    0x8(%ebp),%edx
  800dda:	89 df                	mov    %ebx,%edi
  800ddc:	89 de                	mov    %ebx,%esi
  800dde:	cd 30                	int    $0x30

int
sys_ns_send(void *pkt, uint32_t len)
{
  return syscall(SYS_ns_send, 0, (uint32_t)pkt, len, 0, 0, 0);
}
  800de0:	8b 1c 24             	mov    (%esp),%ebx
  800de3:	8b 74 24 04          	mov    0x4(%esp),%esi
  800de7:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800deb:	89 ec                	mov    %ebp,%esp
  800ded:	5d                   	pop    %ebp
  800dee:	c3                   	ret    

00800def <sys_time_msec>:
	return syscall(SYS_ipc_recv, 1, (uint32_t)dstva, 0, 0, 0, 0);
}

unsigned int
sys_time_msec(void)
{
  800def:	55                   	push   %ebp
  800df0:	89 e5                	mov    %esp,%ebp
  800df2:	83 ec 0c             	sub    $0xc,%esp
  800df5:	89 1c 24             	mov    %ebx,(%esp)
  800df8:	89 74 24 04          	mov    %esi,0x4(%esp)
  800dfc:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800e00:	ba 00 00 00 00       	mov    $0x0,%edx
  800e05:	b8 0e 00 00 00       	mov    $0xe,%eax
  800e0a:	89 d1                	mov    %edx,%ecx
  800e0c:	89 d3                	mov    %edx,%ebx
  800e0e:	89 d7                	mov    %edx,%edi
  800e10:	89 d6                	mov    %edx,%esi
  800e12:	cd 30                	int    $0x30

unsigned int
sys_time_msec(void)
{
	return (unsigned int) syscall(SYS_time_msec, 0, 0, 0, 0, 0, 0);
}
  800e14:	8b 1c 24             	mov    (%esp),%ebx
  800e17:	8b 74 24 04          	mov    0x4(%esp),%esi
  800e1b:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800e1f:	89 ec                	mov    %ebp,%esp
  800e21:	5d                   	pop    %ebp
  800e22:	c3                   	ret    

00800e23 <sys_ipc_recv>:
	return syscall(SYS_ipc_try_send, 1, envid, value, (uint32_t) srcva, perm, 0);
}

int
sys_ipc_recv(void *dstva)
{
  800e23:	55                   	push   %ebp
  800e24:	89 e5                	mov    %esp,%ebp
  800e26:	83 ec 38             	sub    $0x38,%esp
  800e29:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  800e2c:	89 75 f8             	mov    %esi,-0x8(%ebp)
  800e2f:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800e32:	b9 00 00 00 00       	mov    $0x0,%ecx
  800e37:	b8 0d 00 00 00       	mov    $0xd,%eax
  800e3c:	8b 55 08             	mov    0x8(%ebp),%edx
  800e3f:	89 cb                	mov    %ecx,%ebx
  800e41:	89 cf                	mov    %ecx,%edi
  800e43:	89 ce                	mov    %ecx,%esi
  800e45:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  800e47:	85 c0                	test   %eax,%eax
  800e49:	7e 28                	jle    800e73 <sys_ipc_recv+0x50>
		panic("syscall %d returned %d (> 0)", num, ret);
  800e4b:	89 44 24 10          	mov    %eax,0x10(%esp)
  800e4f:	c7 44 24 0c 0d 00 00 	movl   $0xd,0xc(%esp)
  800e56:	00 
  800e57:	c7 44 24 08 4b 33 80 	movl   $0x80334b,0x8(%esp)
  800e5e:	00 
  800e5f:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  800e66:	00 
  800e67:	c7 04 24 68 33 80 00 	movl   $0x803368,(%esp)
  800e6e:	e8 55 f3 ff ff       	call   8001c8 <_panic>

int
sys_ipc_recv(void *dstva)
{
	return syscall(SYS_ipc_recv, 1, (uint32_t)dstva, 0, 0, 0, 0);
}
  800e73:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  800e76:	8b 75 f8             	mov    -0x8(%ebp),%esi
  800e79:	8b 7d fc             	mov    -0x4(%ebp),%edi
  800e7c:	89 ec                	mov    %ebp,%esp
  800e7e:	5d                   	pop    %ebp
  800e7f:	c3                   	ret    

00800e80 <sys_ipc_try_send>:
	return syscall(SYS_env_set_pgfault_upcall, 1, envid, (uint32_t) upcall, 0, 0, 0);
}

int
sys_ipc_try_send(envid_t envid, uint32_t value, void *srcva, int perm)
{
  800e80:	55                   	push   %ebp
  800e81:	89 e5                	mov    %esp,%ebp
  800e83:	83 ec 38             	sub    $0x38,%esp
  800e86:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  800e89:	89 75 f8             	mov    %esi,-0x8(%ebp)
  800e8c:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800e8f:	be 00 00 00 00       	mov    $0x0,%esi
  800e94:	b8 0c 00 00 00       	mov    $0xc,%eax
  800e99:	8b 7d 14             	mov    0x14(%ebp),%edi
  800e9c:	8b 5d 10             	mov    0x10(%ebp),%ebx
  800e9f:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800ea2:	8b 55 08             	mov    0x8(%ebp),%edx
  800ea5:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  800ea7:	85 c0                	test   %eax,%eax
  800ea9:	7e 28                	jle    800ed3 <sys_ipc_try_send+0x53>
		panic("syscall %d returned %d (> 0)", num, ret);
  800eab:	89 44 24 10          	mov    %eax,0x10(%esp)
  800eaf:	c7 44 24 0c 0c 00 00 	movl   $0xc,0xc(%esp)
  800eb6:	00 
  800eb7:	c7 44 24 08 4b 33 80 	movl   $0x80334b,0x8(%esp)
  800ebe:	00 
  800ebf:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  800ec6:	00 
  800ec7:	c7 04 24 68 33 80 00 	movl   $0x803368,(%esp)
  800ece:	e8 f5 f2 ff ff       	call   8001c8 <_panic>

int
sys_ipc_try_send(envid_t envid, uint32_t value, void *srcva, int perm)
{
	return syscall(SYS_ipc_try_send, 1, envid, value, (uint32_t) srcva, perm, 0);
}
  800ed3:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  800ed6:	8b 75 f8             	mov    -0x8(%ebp),%esi
  800ed9:	8b 7d fc             	mov    -0x4(%ebp),%edi
  800edc:	89 ec                	mov    %ebp,%esp
  800ede:	5d                   	pop    %ebp
  800edf:	c3                   	ret    

00800ee0 <sys_env_set_pgfault_upcall>:
	return syscall(SYS_env_set_trapframe, 1, envid, (uint32_t) tf, 0, 0, 0);
}

int
sys_env_set_pgfault_upcall(envid_t envid, void *upcall)
{
  800ee0:	55                   	push   %ebp
  800ee1:	89 e5                	mov    %esp,%ebp
  800ee3:	83 ec 38             	sub    $0x38,%esp
  800ee6:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  800ee9:	89 75 f8             	mov    %esi,-0x8(%ebp)
  800eec:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800eef:	bb 00 00 00 00       	mov    $0x0,%ebx
  800ef4:	b8 0a 00 00 00       	mov    $0xa,%eax
  800ef9:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800efc:	8b 55 08             	mov    0x8(%ebp),%edx
  800eff:	89 df                	mov    %ebx,%edi
  800f01:	89 de                	mov    %ebx,%esi
  800f03:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  800f05:	85 c0                	test   %eax,%eax
  800f07:	7e 28                	jle    800f31 <sys_env_set_pgfault_upcall+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  800f09:	89 44 24 10          	mov    %eax,0x10(%esp)
  800f0d:	c7 44 24 0c 0a 00 00 	movl   $0xa,0xc(%esp)
  800f14:	00 
  800f15:	c7 44 24 08 4b 33 80 	movl   $0x80334b,0x8(%esp)
  800f1c:	00 
  800f1d:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  800f24:	00 
  800f25:	c7 04 24 68 33 80 00 	movl   $0x803368,(%esp)
  800f2c:	e8 97 f2 ff ff       	call   8001c8 <_panic>

int
sys_env_set_pgfault_upcall(envid_t envid, void *upcall)
{
	return syscall(SYS_env_set_pgfault_upcall, 1, envid, (uint32_t) upcall, 0, 0, 0);
}
  800f31:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  800f34:	8b 75 f8             	mov    -0x8(%ebp),%esi
  800f37:	8b 7d fc             	mov    -0x4(%ebp),%edi
  800f3a:	89 ec                	mov    %ebp,%esp
  800f3c:	5d                   	pop    %ebp
  800f3d:	c3                   	ret    

00800f3e <sys_env_set_trapframe>:
	return syscall(SYS_env_set_status, 1, envid, status, 0, 0, 0);
}

int
sys_env_set_trapframe(envid_t envid, struct Trapframe *tf)
{
  800f3e:	55                   	push   %ebp
  800f3f:	89 e5                	mov    %esp,%ebp
  800f41:	83 ec 38             	sub    $0x38,%esp
  800f44:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  800f47:	89 75 f8             	mov    %esi,-0x8(%ebp)
  800f4a:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800f4d:	bb 00 00 00 00       	mov    $0x0,%ebx
  800f52:	b8 09 00 00 00       	mov    $0x9,%eax
  800f57:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800f5a:	8b 55 08             	mov    0x8(%ebp),%edx
  800f5d:	89 df                	mov    %ebx,%edi
  800f5f:	89 de                	mov    %ebx,%esi
  800f61:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  800f63:	85 c0                	test   %eax,%eax
  800f65:	7e 28                	jle    800f8f <sys_env_set_trapframe+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  800f67:	89 44 24 10          	mov    %eax,0x10(%esp)
  800f6b:	c7 44 24 0c 09 00 00 	movl   $0x9,0xc(%esp)
  800f72:	00 
  800f73:	c7 44 24 08 4b 33 80 	movl   $0x80334b,0x8(%esp)
  800f7a:	00 
  800f7b:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  800f82:	00 
  800f83:	c7 04 24 68 33 80 00 	movl   $0x803368,(%esp)
  800f8a:	e8 39 f2 ff ff       	call   8001c8 <_panic>

int
sys_env_set_trapframe(envid_t envid, struct Trapframe *tf)
{
	return syscall(SYS_env_set_trapframe, 1, envid, (uint32_t) tf, 0, 0, 0);
}
  800f8f:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  800f92:	8b 75 f8             	mov    -0x8(%ebp),%esi
  800f95:	8b 7d fc             	mov    -0x4(%ebp),%edi
  800f98:	89 ec                	mov    %ebp,%esp
  800f9a:	5d                   	pop    %ebp
  800f9b:	c3                   	ret    

00800f9c <sys_env_set_status>:

// sys_exofork is inlined in lib.h

int
sys_env_set_status(envid_t envid, int status)
{
  800f9c:	55                   	push   %ebp
  800f9d:	89 e5                	mov    %esp,%ebp
  800f9f:	83 ec 38             	sub    $0x38,%esp
  800fa2:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  800fa5:	89 75 f8             	mov    %esi,-0x8(%ebp)
  800fa8:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800fab:	bb 00 00 00 00       	mov    $0x0,%ebx
  800fb0:	b8 08 00 00 00       	mov    $0x8,%eax
  800fb5:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800fb8:	8b 55 08             	mov    0x8(%ebp),%edx
  800fbb:	89 df                	mov    %ebx,%edi
  800fbd:	89 de                	mov    %ebx,%esi
  800fbf:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  800fc1:	85 c0                	test   %eax,%eax
  800fc3:	7e 28                	jle    800fed <sys_env_set_status+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  800fc5:	89 44 24 10          	mov    %eax,0x10(%esp)
  800fc9:	c7 44 24 0c 08 00 00 	movl   $0x8,0xc(%esp)
  800fd0:	00 
  800fd1:	c7 44 24 08 4b 33 80 	movl   $0x80334b,0x8(%esp)
  800fd8:	00 
  800fd9:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  800fe0:	00 
  800fe1:	c7 04 24 68 33 80 00 	movl   $0x803368,(%esp)
  800fe8:	e8 db f1 ff ff       	call   8001c8 <_panic>

int
sys_env_set_status(envid_t envid, int status)
{
	return syscall(SYS_env_set_status, 1, envid, status, 0, 0, 0);
}
  800fed:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  800ff0:	8b 75 f8             	mov    -0x8(%ebp),%esi
  800ff3:	8b 7d fc             	mov    -0x4(%ebp),%edi
  800ff6:	89 ec                	mov    %ebp,%esp
  800ff8:	5d                   	pop    %ebp
  800ff9:	c3                   	ret    

00800ffa <sys_page_unmap>:
	return syscall(SYS_page_map, 1, srcenv, (uint32_t) srcva, dstenv, (uint32_t) dstva, perm);
}

int
sys_page_unmap(envid_t envid, void *va)
{
  800ffa:	55                   	push   %ebp
  800ffb:	89 e5                	mov    %esp,%ebp
  800ffd:	83 ec 38             	sub    $0x38,%esp
  801000:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801003:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801006:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  801009:	bb 00 00 00 00       	mov    $0x0,%ebx
  80100e:	b8 06 00 00 00       	mov    $0x6,%eax
  801013:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801016:	8b 55 08             	mov    0x8(%ebp),%edx
  801019:	89 df                	mov    %ebx,%edi
  80101b:	89 de                	mov    %ebx,%esi
  80101d:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  80101f:	85 c0                	test   %eax,%eax
  801021:	7e 28                	jle    80104b <sys_page_unmap+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  801023:	89 44 24 10          	mov    %eax,0x10(%esp)
  801027:	c7 44 24 0c 06 00 00 	movl   $0x6,0xc(%esp)
  80102e:	00 
  80102f:	c7 44 24 08 4b 33 80 	movl   $0x80334b,0x8(%esp)
  801036:	00 
  801037:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  80103e:	00 
  80103f:	c7 04 24 68 33 80 00 	movl   $0x803368,(%esp)
  801046:	e8 7d f1 ff ff       	call   8001c8 <_panic>

int
sys_page_unmap(envid_t envid, void *va)
{
	return syscall(SYS_page_unmap, 1, envid, (uint32_t) va, 0, 0, 0);
}
  80104b:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  80104e:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801051:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801054:	89 ec                	mov    %ebp,%esp
  801056:	5d                   	pop    %ebp
  801057:	c3                   	ret    

00801058 <sys_page_map>:
	return syscall(SYS_page_alloc, 1, envid, (uint32_t) va, perm, 0, 0);
}

int
sys_page_map(envid_t srcenv, void *srcva, envid_t dstenv, void *dstva, int perm)
{
  801058:	55                   	push   %ebp
  801059:	89 e5                	mov    %esp,%ebp
  80105b:	83 ec 38             	sub    $0x38,%esp
  80105e:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801061:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801064:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  801067:	b8 05 00 00 00       	mov    $0x5,%eax
  80106c:	8b 75 18             	mov    0x18(%ebp),%esi
  80106f:	8b 7d 14             	mov    0x14(%ebp),%edi
  801072:	8b 5d 10             	mov    0x10(%ebp),%ebx
  801075:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801078:	8b 55 08             	mov    0x8(%ebp),%edx
  80107b:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  80107d:	85 c0                	test   %eax,%eax
  80107f:	7e 28                	jle    8010a9 <sys_page_map+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  801081:	89 44 24 10          	mov    %eax,0x10(%esp)
  801085:	c7 44 24 0c 05 00 00 	movl   $0x5,0xc(%esp)
  80108c:	00 
  80108d:	c7 44 24 08 4b 33 80 	movl   $0x80334b,0x8(%esp)
  801094:	00 
  801095:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  80109c:	00 
  80109d:	c7 04 24 68 33 80 00 	movl   $0x803368,(%esp)
  8010a4:	e8 1f f1 ff ff       	call   8001c8 <_panic>

int
sys_page_map(envid_t srcenv, void *srcva, envid_t dstenv, void *dstva, int perm)
{
	return syscall(SYS_page_map, 1, srcenv, (uint32_t) srcva, dstenv, (uint32_t) dstva, perm);
}
  8010a9:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  8010ac:	8b 75 f8             	mov    -0x8(%ebp),%esi
  8010af:	8b 7d fc             	mov    -0x4(%ebp),%edi
  8010b2:	89 ec                	mov    %ebp,%esp
  8010b4:	5d                   	pop    %ebp
  8010b5:	c3                   	ret    

008010b6 <sys_page_alloc>:
	syscall(SYS_yield, 0, 0, 0, 0, 0, 0);
}

int
sys_page_alloc(envid_t envid, void *va, int perm)
{
  8010b6:	55                   	push   %ebp
  8010b7:	89 e5                	mov    %esp,%ebp
  8010b9:	83 ec 38             	sub    $0x38,%esp
  8010bc:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8010bf:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8010c2:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8010c5:	be 00 00 00 00       	mov    $0x0,%esi
  8010ca:	b8 04 00 00 00       	mov    $0x4,%eax
  8010cf:	8b 5d 10             	mov    0x10(%ebp),%ebx
  8010d2:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  8010d5:	8b 55 08             	mov    0x8(%ebp),%edx
  8010d8:	89 f7                	mov    %esi,%edi
  8010da:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  8010dc:	85 c0                	test   %eax,%eax
  8010de:	7e 28                	jle    801108 <sys_page_alloc+0x52>
		panic("syscall %d returned %d (> 0)", num, ret);
  8010e0:	89 44 24 10          	mov    %eax,0x10(%esp)
  8010e4:	c7 44 24 0c 04 00 00 	movl   $0x4,0xc(%esp)
  8010eb:	00 
  8010ec:	c7 44 24 08 4b 33 80 	movl   $0x80334b,0x8(%esp)
  8010f3:	00 
  8010f4:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  8010fb:	00 
  8010fc:	c7 04 24 68 33 80 00 	movl   $0x803368,(%esp)
  801103:	e8 c0 f0 ff ff       	call   8001c8 <_panic>

int
sys_page_alloc(envid_t envid, void *va, int perm)
{
	return syscall(SYS_page_alloc, 1, envid, (uint32_t) va, perm, 0, 0);
}
  801108:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  80110b:	8b 75 f8             	mov    -0x8(%ebp),%esi
  80110e:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801111:	89 ec                	mov    %ebp,%esp
  801113:	5d                   	pop    %ebp
  801114:	c3                   	ret    

00801115 <sys_yield>:
	 return syscall(SYS_getenvid, 0, 0, 0, 0, 0, 0);
}

void
sys_yield(void)
{
  801115:	55                   	push   %ebp
  801116:	89 e5                	mov    %esp,%ebp
  801118:	83 ec 0c             	sub    $0xc,%esp
  80111b:	89 1c 24             	mov    %ebx,(%esp)
  80111e:	89 74 24 04          	mov    %esi,0x4(%esp)
  801122:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  801126:	ba 00 00 00 00       	mov    $0x0,%edx
  80112b:	b8 0b 00 00 00       	mov    $0xb,%eax
  801130:	89 d1                	mov    %edx,%ecx
  801132:	89 d3                	mov    %edx,%ebx
  801134:	89 d7                	mov    %edx,%edi
  801136:	89 d6                	mov    %edx,%esi
  801138:	cd 30                	int    $0x30

void
sys_yield(void)
{
	syscall(SYS_yield, 0, 0, 0, 0, 0, 0);
}
  80113a:	8b 1c 24             	mov    (%esp),%ebx
  80113d:	8b 74 24 04          	mov    0x4(%esp),%esi
  801141:	8b 7c 24 08          	mov    0x8(%esp),%edi
  801145:	89 ec                	mov    %ebp,%esp
  801147:	5d                   	pop    %ebp
  801148:	c3                   	ret    

00801149 <sys_getenvid>:
	return syscall(SYS_env_destroy, 1, envid, 0, 0, 0, 0);
}

envid_t
sys_getenvid(void)
{
  801149:	55                   	push   %ebp
  80114a:	89 e5                	mov    %esp,%ebp
  80114c:	83 ec 0c             	sub    $0xc,%esp
  80114f:	89 1c 24             	mov    %ebx,(%esp)
  801152:	89 74 24 04          	mov    %esi,0x4(%esp)
  801156:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  80115a:	ba 00 00 00 00       	mov    $0x0,%edx
  80115f:	b8 02 00 00 00       	mov    $0x2,%eax
  801164:	89 d1                	mov    %edx,%ecx
  801166:	89 d3                	mov    %edx,%ebx
  801168:	89 d7                	mov    %edx,%edi
  80116a:	89 d6                	mov    %edx,%esi
  80116c:	cd 30                	int    $0x30

envid_t
sys_getenvid(void)
{
	 return syscall(SYS_getenvid, 0, 0, 0, 0, 0, 0);
}
  80116e:	8b 1c 24             	mov    (%esp),%ebx
  801171:	8b 74 24 04          	mov    0x4(%esp),%esi
  801175:	8b 7c 24 08          	mov    0x8(%esp),%edi
  801179:	89 ec                	mov    %ebp,%esp
  80117b:	5d                   	pop    %ebp
  80117c:	c3                   	ret    

0080117d <sys_env_destroy>:
	return syscall(SYS_cgetc, 0, 0, 0, 0, 0, 0);
}

int
sys_env_destroy(envid_t envid)
{
  80117d:	55                   	push   %ebp
  80117e:	89 e5                	mov    %esp,%ebp
  801180:	83 ec 38             	sub    $0x38,%esp
  801183:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801186:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801189:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  80118c:	b9 00 00 00 00       	mov    $0x0,%ecx
  801191:	b8 03 00 00 00       	mov    $0x3,%eax
  801196:	8b 55 08             	mov    0x8(%ebp),%edx
  801199:	89 cb                	mov    %ecx,%ebx
  80119b:	89 cf                	mov    %ecx,%edi
  80119d:	89 ce                	mov    %ecx,%esi
  80119f:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  8011a1:	85 c0                	test   %eax,%eax
  8011a3:	7e 28                	jle    8011cd <sys_env_destroy+0x50>
		panic("syscall %d returned %d (> 0)", num, ret);
  8011a5:	89 44 24 10          	mov    %eax,0x10(%esp)
  8011a9:	c7 44 24 0c 03 00 00 	movl   $0x3,0xc(%esp)
  8011b0:	00 
  8011b1:	c7 44 24 08 4b 33 80 	movl   $0x80334b,0x8(%esp)
  8011b8:	00 
  8011b9:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  8011c0:	00 
  8011c1:	c7 04 24 68 33 80 00 	movl   $0x803368,(%esp)
  8011c8:	e8 fb ef ff ff       	call   8001c8 <_panic>

int
sys_env_destroy(envid_t envid)
{
	return syscall(SYS_env_destroy, 1, envid, 0, 0, 0, 0);
}
  8011cd:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  8011d0:	8b 75 f8             	mov    -0x8(%ebp),%esi
  8011d3:	8b 7d fc             	mov    -0x4(%ebp),%edi
  8011d6:	89 ec                	mov    %ebp,%esp
  8011d8:	5d                   	pop    %ebp
  8011d9:	c3                   	ret    
  8011da:	00 00                	add    %al,(%eax)
  8011dc:	00 00                	add    %al,(%eax)
	...

008011e0 <fd2num>:
// File descriptor manipulators
// --------------------------------------------------------------

int
fd2num(struct Fd *fd)
{
  8011e0:	55                   	push   %ebp
  8011e1:	89 e5                	mov    %esp,%ebp
  8011e3:	8b 45 08             	mov    0x8(%ebp),%eax
  8011e6:	05 00 00 00 30       	add    $0x30000000,%eax
  8011eb:	c1 e8 0c             	shr    $0xc,%eax
	return ((uintptr_t) fd - FDTABLE) / PGSIZE;
}
  8011ee:	5d                   	pop    %ebp
  8011ef:	c3                   	ret    

008011f0 <fd2data>:

char*
fd2data(struct Fd *fd)
{
  8011f0:	55                   	push   %ebp
  8011f1:	89 e5                	mov    %esp,%ebp
  8011f3:	83 ec 04             	sub    $0x4,%esp
	return INDEX2DATA(fd2num(fd));
  8011f6:	8b 45 08             	mov    0x8(%ebp),%eax
  8011f9:	89 04 24             	mov    %eax,(%esp)
  8011fc:	e8 df ff ff ff       	call   8011e0 <fd2num>
  801201:	05 20 00 0d 00       	add    $0xd0020,%eax
  801206:	c1 e0 0c             	shl    $0xc,%eax
}
  801209:	c9                   	leave  
  80120a:	c3                   	ret    

0080120b <fd_alloc>:
// Returns 0 on success, < 0 on error.  Errors are:
//	-E_MAX_FD: no more file descriptors
// On error, *fd_store is set to 0.
int
fd_alloc(struct Fd **fd_store)
{
  80120b:	55                   	push   %ebp
  80120c:	89 e5                	mov    %esp,%ebp
  80120e:	57                   	push   %edi
  80120f:	56                   	push   %esi
  801210:	53                   	push   %ebx
  801211:	8b 7d 08             	mov    0x8(%ebp),%edi
	int i;
	struct Fd *fd;

	for (i = 0; i < MAXFD; i++) {
		fd = INDEX2FD(i);
		if ((vpd[PDX(fd)] & PTE_P) == 0 || (vpt[VPN(fd)] & PTE_P) == 0) {
  801214:	a1 00 dd 7b ef       	mov    0xef7bdd00,%eax
  801219:	a8 01                	test   $0x1,%al
  80121b:	74 36                	je     801253 <fd_alloc+0x48>
  80121d:	a1 00 00 74 ef       	mov    0xef740000,%eax
  801222:	a8 01                	test   $0x1,%al
  801224:	74 2d                	je     801253 <fd_alloc+0x48>
  801226:	b8 00 10 00 d0       	mov    $0xd0001000,%eax
  80122b:	b9 00 d0 7b ef       	mov    $0xef7bd000,%ecx
  801230:	be 00 00 40 ef       	mov    $0xef400000,%esi
  801235:	89 c3                	mov    %eax,%ebx
  801237:	89 c2                	mov    %eax,%edx
  801239:	c1 ea 16             	shr    $0x16,%edx
  80123c:	8b 14 91             	mov    (%ecx,%edx,4),%edx
  80123f:	f6 c2 01             	test   $0x1,%dl
  801242:	74 14                	je     801258 <fd_alloc+0x4d>
  801244:	89 c2                	mov    %eax,%edx
  801246:	c1 ea 0c             	shr    $0xc,%edx
  801249:	8b 14 96             	mov    (%esi,%edx,4),%edx
  80124c:	f6 c2 01             	test   $0x1,%dl
  80124f:	75 10                	jne    801261 <fd_alloc+0x56>
  801251:	eb 05                	jmp    801258 <fd_alloc+0x4d>
  801253:	bb 00 00 00 d0       	mov    $0xd0000000,%ebx
			*fd_store = fd;
  801258:	89 1f                	mov    %ebx,(%edi)
  80125a:	b8 00 00 00 00       	mov    $0x0,%eax
			return 0;
  80125f:	eb 17                	jmp    801278 <fd_alloc+0x6d>
  801261:	05 00 10 00 00       	add    $0x1000,%eax
fd_alloc(struct Fd **fd_store)
{
	int i;
	struct Fd *fd;

	for (i = 0; i < MAXFD; i++) {
  801266:	3d 00 00 02 d0       	cmp    $0xd0020000,%eax
  80126b:	75 c8                	jne    801235 <fd_alloc+0x2a>
		if ((vpd[PDX(fd)] & PTE_P) == 0 || (vpt[VPN(fd)] & PTE_P) == 0) {
			*fd_store = fd;
			return 0;
		}
	}
	*fd_store = 0;
  80126d:	c7 07 00 00 00 00    	movl   $0x0,(%edi)
  801273:	b8 f6 ff ff ff       	mov    $0xfffffff6,%eax
	return -E_MAX_OPEN;
}
  801278:	5b                   	pop    %ebx
  801279:	5e                   	pop    %esi
  80127a:	5f                   	pop    %edi
  80127b:	5d                   	pop    %ebp
  80127c:	c3                   	ret    

0080127d <fd_lookup>:
// Returns 0 on success (the page is in range and mapped), < 0 on error.
// Errors are:
//	-E_INVAL: fdnum was either not in range or not mapped.
int
fd_lookup(int fdnum, struct Fd **fd_store)
{
  80127d:	55                   	push   %ebp
  80127e:	89 e5                	mov    %esp,%ebp
	struct Fd *fd=NULL;

	if (fdnum < 0 || fdnum >= MAXFD) {
  801280:	8b 45 08             	mov    0x8(%ebp),%eax
  801283:	83 f8 1f             	cmp    $0x1f,%eax
  801286:	77 36                	ja     8012be <fd_lookup+0x41>
		if (debug)
			cprintf("[%08x] bad fd %d\n", env->env_id, fd);
		return -E_INVAL;
	}
	fd = INDEX2FD(fdnum);
  801288:	05 00 00 0d 00       	add    $0xd0000,%eax
  80128d:	c1 e0 0c             	shl    $0xc,%eax
	if (!(vpd[PDX(fd)] & PTE_P) || !(vpt[VPN(fd)] & PTE_P)) {
  801290:	89 c2                	mov    %eax,%edx
  801292:	c1 ea 16             	shr    $0x16,%edx
  801295:	8b 14 95 00 d0 7b ef 	mov    -0x10843000(,%edx,4),%edx
  80129c:	f6 c2 01             	test   $0x1,%dl
  80129f:	74 1d                	je     8012be <fd_lookup+0x41>
  8012a1:	89 c2                	mov    %eax,%edx
  8012a3:	c1 ea 0c             	shr    $0xc,%edx
  8012a6:	8b 14 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%edx
  8012ad:	f6 c2 01             	test   $0x1,%dl
  8012b0:	74 0c                	je     8012be <fd_lookup+0x41>
		if (debug)
			cprintf("[%08x] closed fd %d\n", env->env_id, fd);
		return -E_INVAL;
	}
	*fd_store = fd;
  8012b2:	8b 55 0c             	mov    0xc(%ebp),%edx
  8012b5:	89 02                	mov    %eax,(%edx)
  8012b7:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
  8012bc:	eb 05                	jmp    8012c3 <fd_lookup+0x46>
  8012be:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
}
  8012c3:	5d                   	pop    %ebp
  8012c4:	c3                   	ret    

008012c5 <seek>:
	return (*dev->dev_write)(fd, buf, n);
}

int
seek(int fdnum, off_t offset)
{
  8012c5:	55                   	push   %ebp
  8012c6:	89 e5                	mov    %esp,%ebp
  8012c8:	83 ec 18             	sub    $0x18,%esp
	int r;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0)
  8012cb:	8d 45 fc             	lea    -0x4(%ebp),%eax
  8012ce:	89 44 24 04          	mov    %eax,0x4(%esp)
  8012d2:	8b 45 08             	mov    0x8(%ebp),%eax
  8012d5:	89 04 24             	mov    %eax,(%esp)
  8012d8:	e8 a0 ff ff ff       	call   80127d <fd_lookup>
  8012dd:	85 c0                	test   %eax,%eax
  8012df:	78 0e                	js     8012ef <seek+0x2a>
		return r;
	fd->fd_offset = offset;
  8012e1:	8b 45 fc             	mov    -0x4(%ebp),%eax
  8012e4:	8b 55 0c             	mov    0xc(%ebp),%edx
  8012e7:	89 50 04             	mov    %edx,0x4(%eax)
  8012ea:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
}
  8012ef:	c9                   	leave  
  8012f0:	c3                   	ret    

008012f1 <dev_lookup>:
	0
};

int
dev_lookup(int dev_id, struct Dev **dev)
{
  8012f1:	55                   	push   %ebp
  8012f2:	89 e5                	mov    %esp,%ebp
  8012f4:	56                   	push   %esi
  8012f5:	53                   	push   %ebx
  8012f6:	83 ec 10             	sub    $0x10,%esp
  8012f9:	8b 4d 08             	mov    0x8(%ebp),%ecx
  8012fc:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int i;
	for (i = 0; devtab[i]; i++)
		if (devtab[i]->dev_id == dev_id) {
			*dev = devtab[i];
			return 0;
  8012ff:	ba 00 00 00 00       	mov    $0x0,%edx
int
dev_lookup(int dev_id, struct Dev **dev)
{
	int i;
	for (i = 0; devtab[i]; i++)
		if (devtab[i]->dev_id == dev_id) {
  801304:	b8 04 70 80 00       	mov    $0x807004,%eax
  801309:	39 0d 04 70 80 00    	cmp    %ecx,0x807004
  80130f:	75 11                	jne    801322 <dev_lookup+0x31>
  801311:	eb 04                	jmp    801317 <dev_lookup+0x26>
  801313:	39 08                	cmp    %ecx,(%eax)
  801315:	75 10                	jne    801327 <dev_lookup+0x36>
			*dev = devtab[i];
  801317:	89 03                	mov    %eax,(%ebx)
  801319:	b8 00 00 00 00       	mov    $0x0,%eax
			return 0;
  80131e:	66 90                	xchg   %ax,%ax
  801320:	eb 36                	jmp    801358 <dev_lookup+0x67>

int
dev_lookup(int dev_id, struct Dev **dev)
{
	int i;
	for (i = 0; devtab[i]; i++)
  801322:	be f4 33 80 00       	mov    $0x8033f4,%esi
  801327:	83 c2 01             	add    $0x1,%edx
  80132a:	8b 04 96             	mov    (%esi,%edx,4),%eax
  80132d:	85 c0                	test   %eax,%eax
  80132f:	75 e2                	jne    801313 <dev_lookup+0x22>
		if (devtab[i]->dev_id == dev_id) {
			*dev = devtab[i];
			return 0;
		}
	cprintf("[%08x] unknown device type %d\n", env->env_id, dev_id);
  801331:	a1 74 70 80 00       	mov    0x807074,%eax
  801336:	8b 40 4c             	mov    0x4c(%eax),%eax
  801339:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  80133d:	89 44 24 04          	mov    %eax,0x4(%esp)
  801341:	c7 04 24 78 33 80 00 	movl   $0x803378,(%esp)
  801348:	e8 40 ef ff ff       	call   80028d <cprintf>
	*dev = 0;
  80134d:	c7 03 00 00 00 00    	movl   $0x0,(%ebx)
  801353:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
	return -E_INVAL;
}
  801358:	83 c4 10             	add    $0x10,%esp
  80135b:	5b                   	pop    %ebx
  80135c:	5e                   	pop    %esi
  80135d:	5d                   	pop    %ebp
  80135e:	c3                   	ret    

0080135f <fstat>:
	return (*dev->dev_trunc)(fd, newsize);
}

int
fstat(int fdnum, struct Stat *stat)
{
  80135f:	55                   	push   %ebp
  801360:	89 e5                	mov    %esp,%ebp
  801362:	53                   	push   %ebx
  801363:	83 ec 24             	sub    $0x24,%esp
  801366:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801369:	8d 45 f0             	lea    -0x10(%ebp),%eax
  80136c:	89 44 24 04          	mov    %eax,0x4(%esp)
  801370:	8b 45 08             	mov    0x8(%ebp),%eax
  801373:	89 04 24             	mov    %eax,(%esp)
  801376:	e8 02 ff ff ff       	call   80127d <fd_lookup>
  80137b:	85 c0                	test   %eax,%eax
  80137d:	78 53                	js     8013d2 <fstat+0x73>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  80137f:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801382:	89 44 24 04          	mov    %eax,0x4(%esp)
  801386:	8b 45 f0             	mov    -0x10(%ebp),%eax
  801389:	8b 00                	mov    (%eax),%eax
  80138b:	89 04 24             	mov    %eax,(%esp)
  80138e:	e8 5e ff ff ff       	call   8012f1 <dev_lookup>
{
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801393:	85 c0                	test   %eax,%eax
  801395:	78 3b                	js     8013d2 <fstat+0x73>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if (!dev->dev_stat)
  801397:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  80139c:	8b 55 f4             	mov    -0xc(%ebp),%edx
  80139f:	83 7a 14 00          	cmpl   $0x0,0x14(%edx)
  8013a3:	74 2d                	je     8013d2 <fstat+0x73>
		return -E_NOT_SUPP;
	stat->st_name[0] = 0;
  8013a5:	c6 03 00             	movb   $0x0,(%ebx)
	stat->st_size = 0;
  8013a8:	c7 83 80 00 00 00 00 	movl   $0x0,0x80(%ebx)
  8013af:	00 00 00 
	stat->st_isdir = 0;
  8013b2:	c7 83 84 00 00 00 00 	movl   $0x0,0x84(%ebx)
  8013b9:	00 00 00 
	stat->st_dev = dev;
  8013bc:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8013bf:	89 83 88 00 00 00    	mov    %eax,0x88(%ebx)
	return (*dev->dev_stat)(fd, stat);
  8013c5:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8013c9:	8b 55 f0             	mov    -0x10(%ebp),%edx
  8013cc:	89 14 24             	mov    %edx,(%esp)
  8013cf:	ff 50 14             	call   *0x14(%eax)
}
  8013d2:	83 c4 24             	add    $0x24,%esp
  8013d5:	5b                   	pop    %ebx
  8013d6:	5d                   	pop    %ebp
  8013d7:	c3                   	ret    

008013d8 <ftruncate>:
	return 0;
}

int
ftruncate(int fdnum, off_t newsize)
{
  8013d8:	55                   	push   %ebp
  8013d9:	89 e5                	mov    %esp,%ebp
  8013db:	53                   	push   %ebx
  8013dc:	83 ec 24             	sub    $0x24,%esp
  8013df:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
  8013e2:	8d 45 f0             	lea    -0x10(%ebp),%eax
  8013e5:	89 44 24 04          	mov    %eax,0x4(%esp)
  8013e9:	89 1c 24             	mov    %ebx,(%esp)
  8013ec:	e8 8c fe ff ff       	call   80127d <fd_lookup>
  8013f1:	85 c0                	test   %eax,%eax
  8013f3:	78 5f                	js     801454 <ftruncate+0x7c>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  8013f5:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8013f8:	89 44 24 04          	mov    %eax,0x4(%esp)
  8013fc:	8b 45 f0             	mov    -0x10(%ebp),%eax
  8013ff:	8b 00                	mov    (%eax),%eax
  801401:	89 04 24             	mov    %eax,(%esp)
  801404:	e8 e8 fe ff ff       	call   8012f1 <dev_lookup>
ftruncate(int fdnum, off_t newsize)
{
	int r;
	struct Dev *dev;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
  801409:	85 c0                	test   %eax,%eax
  80140b:	78 47                	js     801454 <ftruncate+0x7c>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
  80140d:	8b 55 f0             	mov    -0x10(%ebp),%edx
  801410:	f6 42 08 03          	testb  $0x3,0x8(%edx)
  801414:	75 23                	jne    801439 <ftruncate+0x61>
		cprintf("[%08x] ftruncate %d -- bad mode\n",
			env->env_id, fdnum); 
  801416:	a1 74 70 80 00       	mov    0x807074,%eax
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
		cprintf("[%08x] ftruncate %d -- bad mode\n",
  80141b:	8b 40 4c             	mov    0x4c(%eax),%eax
  80141e:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  801422:	89 44 24 04          	mov    %eax,0x4(%esp)
  801426:	c7 04 24 98 33 80 00 	movl   $0x803398,(%esp)
  80142d:	e8 5b ee ff ff       	call   80028d <cprintf>
  801432:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
			env->env_id, fdnum); 
		return -E_INVAL;
  801437:	eb 1b                	jmp    801454 <ftruncate+0x7c>
	}
	if (!dev->dev_trunc)
  801439:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80143c:	8b 48 18             	mov    0x18(%eax),%ecx
  80143f:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  801444:	85 c9                	test   %ecx,%ecx
  801446:	74 0c                	je     801454 <ftruncate+0x7c>
		return -E_NOT_SUPP;
	return (*dev->dev_trunc)(fd, newsize);
  801448:	8b 45 0c             	mov    0xc(%ebp),%eax
  80144b:	89 44 24 04          	mov    %eax,0x4(%esp)
  80144f:	89 14 24             	mov    %edx,(%esp)
  801452:	ff d1                	call   *%ecx
}
  801454:	83 c4 24             	add    $0x24,%esp
  801457:	5b                   	pop    %ebx
  801458:	5d                   	pop    %ebp
  801459:	c3                   	ret    

0080145a <write>:
	return tot;
}

ssize_t
write(int fdnum, const void *buf, size_t n)
{
  80145a:	55                   	push   %ebp
  80145b:	89 e5                	mov    %esp,%ebp
  80145d:	53                   	push   %ebx
  80145e:	83 ec 24             	sub    $0x24,%esp
  801461:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801464:	8d 45 f0             	lea    -0x10(%ebp),%eax
  801467:	89 44 24 04          	mov    %eax,0x4(%esp)
  80146b:	89 1c 24             	mov    %ebx,(%esp)
  80146e:	e8 0a fe ff ff       	call   80127d <fd_lookup>
  801473:	85 c0                	test   %eax,%eax
  801475:	78 66                	js     8014dd <write+0x83>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  801477:	8d 45 f4             	lea    -0xc(%ebp),%eax
  80147a:	89 44 24 04          	mov    %eax,0x4(%esp)
  80147e:	8b 45 f0             	mov    -0x10(%ebp),%eax
  801481:	8b 00                	mov    (%eax),%eax
  801483:	89 04 24             	mov    %eax,(%esp)
  801486:	e8 66 fe ff ff       	call   8012f1 <dev_lookup>
{
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  80148b:	85 c0                	test   %eax,%eax
  80148d:	78 4e                	js     8014dd <write+0x83>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
  80148f:	8b 55 f0             	mov    -0x10(%ebp),%edx
  801492:	f6 42 08 03          	testb  $0x3,0x8(%edx)
  801496:	75 23                	jne    8014bb <write+0x61>
		cprintf("[%08x] write %d -- bad mode\n", env->env_id, fdnum);
  801498:	a1 74 70 80 00       	mov    0x807074,%eax
  80149d:	8b 40 4c             	mov    0x4c(%eax),%eax
  8014a0:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8014a4:	89 44 24 04          	mov    %eax,0x4(%esp)
  8014a8:	c7 04 24 b9 33 80 00 	movl   $0x8033b9,(%esp)
  8014af:	e8 d9 ed ff ff       	call   80028d <cprintf>
  8014b4:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
		return -E_INVAL;
  8014b9:	eb 22                	jmp    8014dd <write+0x83>
	}
	if (debug)
		cprintf("write %d %p %d via dev %s\n",
			fdnum, buf, n, dev->dev_name);
	if (!dev->dev_write)
  8014bb:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8014be:	8b 48 0c             	mov    0xc(%eax),%ecx
  8014c1:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  8014c6:	85 c9                	test   %ecx,%ecx
  8014c8:	74 13                	je     8014dd <write+0x83>
		return -E_NOT_SUPP;
	return (*dev->dev_write)(fd, buf, n);
  8014ca:	8b 45 10             	mov    0x10(%ebp),%eax
  8014cd:	89 44 24 08          	mov    %eax,0x8(%esp)
  8014d1:	8b 45 0c             	mov    0xc(%ebp),%eax
  8014d4:	89 44 24 04          	mov    %eax,0x4(%esp)
  8014d8:	89 14 24             	mov    %edx,(%esp)
  8014db:	ff d1                	call   *%ecx
}
  8014dd:	83 c4 24             	add    $0x24,%esp
  8014e0:	5b                   	pop    %ebx
  8014e1:	5d                   	pop    %ebp
  8014e2:	c3                   	ret    

008014e3 <read>:
	return r;
}

ssize_t
read(int fdnum, void *buf, size_t n)
{
  8014e3:	55                   	push   %ebp
  8014e4:	89 e5                	mov    %esp,%ebp
  8014e6:	57                   	push   %edi
  8014e7:	56                   	push   %esi
  8014e8:	53                   	push   %ebx
  8014e9:	83 ec 2c             	sub    $0x2c,%esp
  8014ec:	8b 5d 08             	mov    0x8(%ebp),%ebx
  8014ef:	8b 75 10             	mov    0x10(%ebp),%esi
	int r;
	int m, tot;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  8014f2:	8d 45 e0             	lea    -0x20(%ebp),%eax
  8014f5:	89 44 24 04          	mov    %eax,0x4(%esp)
  8014f9:	89 1c 24             	mov    %ebx,(%esp)
  8014fc:	e8 7c fd ff ff       	call   80127d <fd_lookup>
  801501:	85 c0                	test   %eax,%eax
  801503:	0f 88 b0 00 00 00    	js     8015b9 <read+0xd6>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  801509:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  80150c:	89 44 24 04          	mov    %eax,0x4(%esp)
  801510:	8b 45 e0             	mov    -0x20(%ebp),%eax
  801513:	8b 00                	mov    (%eax),%eax
  801515:	89 04 24             	mov    %eax,(%esp)
  801518:	e8 d4 fd ff ff       	call   8012f1 <dev_lookup>
	int r;
	int m, tot;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  80151d:	85 c0                	test   %eax,%eax
  80151f:	0f 88 94 00 00 00    	js     8015b9 <read+0xd6>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_WRONLY) {
  801525:	8b 45 e0             	mov    -0x20(%ebp),%eax
  801528:	8b 40 08             	mov    0x8(%eax),%eax
  80152b:	83 e0 03             	and    $0x3,%eax
  80152e:	83 f8 01             	cmp    $0x1,%eax
  801531:	75 23                	jne    801556 <read+0x73>
		cprintf("[%08x] read %d -- bad mode\n", env->env_id, fdnum); 
  801533:	a1 74 70 80 00       	mov    0x807074,%eax
  801538:	8b 40 4c             	mov    0x4c(%eax),%eax
  80153b:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  80153f:	89 44 24 04          	mov    %eax,0x4(%esp)
  801543:	c7 04 24 d6 33 80 00 	movl   $0x8033d6,(%esp)
  80154a:	e8 3e ed ff ff       	call   80028d <cprintf>
  80154f:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
		return -E_INVAL;
  801554:	eb 63                	jmp    8015b9 <read+0xd6>
	}
	if (!dev->dev_read)
  801556:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  80155b:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  80155e:	83 7a 08 00          	cmpl   $0x0,0x8(%edx)
  801562:	74 55                	je     8015b9 <read+0xd6>
		return -E_NOT_SUPP;

  for (tot = 0; tot < n; tot += m) {
  801564:	ba 00 00 00 00       	mov    $0x0,%edx
  801569:	bb 00 00 00 00       	mov    $0x0,%ebx
  80156e:	b8 00 00 00 00       	mov    $0x0,%eax
  801573:	85 f6                	test   %esi,%esi
  801575:	74 42                	je     8015b9 <read+0xd6>
    int count=0;
    if ((n-tot)/PGSIZE == 0)
  801577:	bf 00 10 00 00       	mov    $0x1000,%edi
  80157c:	89 f0                	mov    %esi,%eax
  80157e:	29 d0                	sub    %edx,%eax
  801580:	89 c1                	mov    %eax,%ecx
  801582:	81 e1 ff 0f 00 00    	and    $0xfff,%ecx
  801588:	3d 00 10 00 00       	cmp    $0x1000,%eax
  80158d:	0f 43 cf             	cmovae %edi,%ecx
      count = (n-tot)%PGSIZE;
    else
      count = PGSIZE;

	  m = (*dev->dev_read)(fd, (char *)buf + tot, count);
  801590:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  801594:	03 55 0c             	add    0xc(%ebp),%edx
  801597:	89 54 24 04          	mov    %edx,0x4(%esp)
  80159b:	8b 45 e0             	mov    -0x20(%ebp),%eax
  80159e:	89 04 24             	mov    %eax,(%esp)
  8015a1:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8015a4:	ff 50 08             	call   *0x8(%eax)
		if (m < 0)
  8015a7:	85 c0                	test   %eax,%eax
  8015a9:	78 0e                	js     8015b9 <read+0xd6>
			return m;
		if (m == 0)
  8015ab:	85 c0                	test   %eax,%eax
  8015ad:	74 08                	je     8015b7 <read+0xd4>
		return -E_INVAL;
	}
	if (!dev->dev_read)
		return -E_NOT_SUPP;

  for (tot = 0; tot < n; tot += m) {
  8015af:	01 c3                	add    %eax,%ebx
  8015b1:	89 da                	mov    %ebx,%edx
  8015b3:	39 f3                	cmp    %esi,%ebx
  8015b5:	72 c5                	jb     80157c <read+0x99>
  8015b7:	89 d8                	mov    %ebx,%eax
			return m;
		if (m == 0)
			break;
	}
	return tot;
}
  8015b9:	83 c4 2c             	add    $0x2c,%esp
  8015bc:	5b                   	pop    %ebx
  8015bd:	5e                   	pop    %esi
  8015be:	5f                   	pop    %edi
  8015bf:	5d                   	pop    %ebp
  8015c0:	c3                   	ret    

008015c1 <readn>:

ssize_t
readn(int fdnum, void *buf, size_t n)
{
  8015c1:	55                   	push   %ebp
  8015c2:	89 e5                	mov    %esp,%ebp
  8015c4:	57                   	push   %edi
  8015c5:	56                   	push   %esi
  8015c6:	53                   	push   %ebx
  8015c7:	83 ec 1c             	sub    $0x1c,%esp
  8015ca:	8b 7d 08             	mov    0x8(%ebp),%edi
  8015cd:	8b 75 10             	mov    0x10(%ebp),%esi
	int m, tot;
  struct Fd *fd = INDEX2FD(fdnum);

	for (tot = 0; tot < n; tot += m) {
  8015d0:	ba 00 00 00 00       	mov    $0x0,%edx
  8015d5:	bb 00 00 00 00       	mov    $0x0,%ebx
  8015da:	b8 00 00 00 00       	mov    $0x0,%eax
  8015df:	85 f6                	test   %esi,%esi
  8015e1:	74 29                	je     80160c <readn+0x4b>
		m = read(fdnum, (char*)buf + tot, n - tot);
  8015e3:	89 f0                	mov    %esi,%eax
  8015e5:	29 d0                	sub    %edx,%eax
  8015e7:	89 44 24 08          	mov    %eax,0x8(%esp)
  8015eb:	03 55 0c             	add    0xc(%ebp),%edx
  8015ee:	89 54 24 04          	mov    %edx,0x4(%esp)
  8015f2:	89 3c 24             	mov    %edi,(%esp)
  8015f5:	e8 e9 fe ff ff       	call   8014e3 <read>
		if (m < 0)
  8015fa:	85 c0                	test   %eax,%eax
  8015fc:	78 0e                	js     80160c <readn+0x4b>
			return m;
		if (m == 0)
  8015fe:	85 c0                	test   %eax,%eax
  801600:	74 08                	je     80160a <readn+0x49>
readn(int fdnum, void *buf, size_t n)
{
	int m, tot;
  struct Fd *fd = INDEX2FD(fdnum);

	for (tot = 0; tot < n; tot += m) {
  801602:	01 c3                	add    %eax,%ebx
  801604:	89 da                	mov    %ebx,%edx
  801606:	39 f3                	cmp    %esi,%ebx
  801608:	72 d9                	jb     8015e3 <readn+0x22>
  80160a:	89 d8                	mov    %ebx,%eax
			return m;
		if (m == 0)
			break;
	}
	return tot;
}
  80160c:	83 c4 1c             	add    $0x1c,%esp
  80160f:	5b                   	pop    %ebx
  801610:	5e                   	pop    %esi
  801611:	5f                   	pop    %edi
  801612:	5d                   	pop    %ebp
  801613:	c3                   	ret    

00801614 <fd_close>:
// If 'must_exist' is 1, then fd_close returns -E_INVAL when passed a
// closed or nonexistent file descriptor.
// Returns 0 on success, < 0 on error.
int
fd_close(struct Fd *fd, bool must_exist)
{
  801614:	55                   	push   %ebp
  801615:	89 e5                	mov    %esp,%ebp
  801617:	83 ec 28             	sub    $0x28,%esp
  80161a:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  80161d:	89 75 fc             	mov    %esi,-0x4(%ebp)
  801620:	8b 75 08             	mov    0x8(%ebp),%esi
	struct Fd *fd2;
	struct Dev *dev;
	int r;
	if ((r = fd_lookup(fd2num(fd), &fd2)) < 0
  801623:	89 34 24             	mov    %esi,(%esp)
  801626:	e8 b5 fb ff ff       	call   8011e0 <fd2num>
  80162b:	8d 55 f4             	lea    -0xc(%ebp),%edx
  80162e:	89 54 24 04          	mov    %edx,0x4(%esp)
  801632:	89 04 24             	mov    %eax,(%esp)
  801635:	e8 43 fc ff ff       	call   80127d <fd_lookup>
  80163a:	89 c3                	mov    %eax,%ebx
  80163c:	85 c0                	test   %eax,%eax
  80163e:	78 05                	js     801645 <fd_close+0x31>
  801640:	3b 75 f4             	cmp    -0xc(%ebp),%esi
  801643:	74 0e                	je     801653 <fd_close+0x3f>
	    || fd != fd2)
		return (must_exist ? r : 0);
  801645:	83 7d 0c 00          	cmpl   $0x0,0xc(%ebp)
  801649:	b8 00 00 00 00       	mov    $0x0,%eax
  80164e:	0f 44 d8             	cmove  %eax,%ebx
  801651:	eb 3d                	jmp    801690 <fd_close+0x7c>
	if ((r = dev_lookup(fd->fd_dev_id, &dev)) >= 0) {
  801653:	8d 45 f0             	lea    -0x10(%ebp),%eax
  801656:	89 44 24 04          	mov    %eax,0x4(%esp)
  80165a:	8b 06                	mov    (%esi),%eax
  80165c:	89 04 24             	mov    %eax,(%esp)
  80165f:	e8 8d fc ff ff       	call   8012f1 <dev_lookup>
  801664:	89 c3                	mov    %eax,%ebx
  801666:	85 c0                	test   %eax,%eax
  801668:	78 16                	js     801680 <fd_close+0x6c>
		if (dev->dev_close)
  80166a:	8b 45 f0             	mov    -0x10(%ebp),%eax
  80166d:	8b 40 10             	mov    0x10(%eax),%eax
  801670:	bb 00 00 00 00       	mov    $0x0,%ebx
  801675:	85 c0                	test   %eax,%eax
  801677:	74 07                	je     801680 <fd_close+0x6c>
			r = (*dev->dev_close)(fd);
  801679:	89 34 24             	mov    %esi,(%esp)
  80167c:	ff d0                	call   *%eax
  80167e:	89 c3                	mov    %eax,%ebx
		else
			r = 0;
	}
	// Make sure fd is unmapped.  Might be a no-op if
	// (*dev->dev_close)(fd) already unmapped it.
	(void) sys_page_unmap(0, fd);
  801680:	89 74 24 04          	mov    %esi,0x4(%esp)
  801684:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80168b:	e8 6a f9 ff ff       	call   800ffa <sys_page_unmap>
	return r;
}
  801690:	89 d8                	mov    %ebx,%eax
  801692:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  801695:	8b 75 fc             	mov    -0x4(%ebp),%esi
  801698:	89 ec                	mov    %ebp,%esp
  80169a:	5d                   	pop    %ebp
  80169b:	c3                   	ret    

0080169c <close>:
	return -E_INVAL;
}

int
close(int fdnum)
{
  80169c:	55                   	push   %ebp
  80169d:	89 e5                	mov    %esp,%ebp
  80169f:	83 ec 28             	sub    $0x28,%esp
	struct Fd *fd;
	int r;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  8016a2:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8016a5:	89 44 24 04          	mov    %eax,0x4(%esp)
  8016a9:	8b 45 08             	mov    0x8(%ebp),%eax
  8016ac:	89 04 24             	mov    %eax,(%esp)
  8016af:	e8 c9 fb ff ff       	call   80127d <fd_lookup>
  8016b4:	85 c0                	test   %eax,%eax
  8016b6:	78 13                	js     8016cb <close+0x2f>
		return r;
	else
		return fd_close(fd, 1);
  8016b8:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  8016bf:	00 
  8016c0:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8016c3:	89 04 24             	mov    %eax,(%esp)
  8016c6:	e8 49 ff ff ff       	call   801614 <fd_close>
}
  8016cb:	c9                   	leave  
  8016cc:	c3                   	ret    

008016cd <stat>:
	return (*dev->dev_stat)(fd, stat);
}

int
stat(const char *path, struct Stat *stat)
{
  8016cd:	55                   	push   %ebp
  8016ce:	89 e5                	mov    %esp,%ebp
  8016d0:	83 ec 18             	sub    $0x18,%esp
  8016d3:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  8016d6:	89 75 fc             	mov    %esi,-0x4(%ebp)
	int fd, r;

	if ((fd = open(path, O_RDONLY)) < 0)
  8016d9:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  8016e0:	00 
  8016e1:	8b 45 08             	mov    0x8(%ebp),%eax
  8016e4:	89 04 24             	mov    %eax,(%esp)
  8016e7:	e8 80 03 00 00       	call   801a6c <open>
  8016ec:	89 c3                	mov    %eax,%ebx
  8016ee:	85 c0                	test   %eax,%eax
  8016f0:	78 1b                	js     80170d <stat+0x40>
		return fd;
	r = fstat(fd, stat);
  8016f2:	8b 45 0c             	mov    0xc(%ebp),%eax
  8016f5:	89 44 24 04          	mov    %eax,0x4(%esp)
  8016f9:	89 1c 24             	mov    %ebx,(%esp)
  8016fc:	e8 5e fc ff ff       	call   80135f <fstat>
  801701:	89 c6                	mov    %eax,%esi
	close(fd);
  801703:	89 1c 24             	mov    %ebx,(%esp)
  801706:	e8 91 ff ff ff       	call   80169c <close>
  80170b:	89 f3                	mov    %esi,%ebx
	return r;
}
  80170d:	89 d8                	mov    %ebx,%eax
  80170f:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  801712:	8b 75 fc             	mov    -0x4(%ebp),%esi
  801715:	89 ec                	mov    %ebp,%esp
  801717:	5d                   	pop    %ebp
  801718:	c3                   	ret    

00801719 <close_all>:
		return fd_close(fd, 1);
}

void
close_all(void)
{
  801719:	55                   	push   %ebp
  80171a:	89 e5                	mov    %esp,%ebp
  80171c:	53                   	push   %ebx
  80171d:	83 ec 14             	sub    $0x14,%esp
  801720:	bb 00 00 00 00       	mov    $0x0,%ebx
	int i;
	for (i = 0; i < MAXFD; i++)
		close(i);
  801725:	89 1c 24             	mov    %ebx,(%esp)
  801728:	e8 6f ff ff ff       	call   80169c <close>

void
close_all(void)
{
	int i;
	for (i = 0; i < MAXFD; i++)
  80172d:	83 c3 01             	add    $0x1,%ebx
  801730:	83 fb 20             	cmp    $0x20,%ebx
  801733:	75 f0                	jne    801725 <close_all+0xc>
		close(i);
}
  801735:	83 c4 14             	add    $0x14,%esp
  801738:	5b                   	pop    %ebx
  801739:	5d                   	pop    %ebp
  80173a:	c3                   	ret    

0080173b <dup>:
// file and the file offset of the other.
// Closes any previously open file descriptor at 'newfdnum'.
// This is implemented using virtual memory tricks (of course!).
int
dup(int oldfdnum, int newfdnum)
{
  80173b:	55                   	push   %ebp
  80173c:	89 e5                	mov    %esp,%ebp
  80173e:	83 ec 58             	sub    $0x58,%esp
  801741:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801744:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801747:	89 7d fc             	mov    %edi,-0x4(%ebp)
  80174a:	8b 7d 0c             	mov    0xc(%ebp),%edi
	int r;
	char *ova, *nva;
	pte_t pte;
	struct Fd *oldfd, *newfd;

	if ((r = fd_lookup(oldfdnum, &oldfd)) < 0)
  80174d:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  801750:	89 44 24 04          	mov    %eax,0x4(%esp)
  801754:	8b 45 08             	mov    0x8(%ebp),%eax
  801757:	89 04 24             	mov    %eax,(%esp)
  80175a:	e8 1e fb ff ff       	call   80127d <fd_lookup>
  80175f:	89 c3                	mov    %eax,%ebx
  801761:	85 c0                	test   %eax,%eax
  801763:	0f 88 e0 00 00 00    	js     801849 <dup+0x10e>
		return r;
	close(newfdnum);
  801769:	89 3c 24             	mov    %edi,(%esp)
  80176c:	e8 2b ff ff ff       	call   80169c <close>

	newfd = INDEX2FD(newfdnum);
  801771:	8d b7 00 00 0d 00    	lea    0xd0000(%edi),%esi
  801777:	c1 e6 0c             	shl    $0xc,%esi
	ova = fd2data(oldfd);
  80177a:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  80177d:	89 04 24             	mov    %eax,(%esp)
  801780:	e8 6b fa ff ff       	call   8011f0 <fd2data>
  801785:	89 c3                	mov    %eax,%ebx
	nva = fd2data(newfd);
  801787:	89 34 24             	mov    %esi,(%esp)
  80178a:	e8 61 fa ff ff       	call   8011f0 <fd2data>
  80178f:	89 45 d4             	mov    %eax,-0x2c(%ebp)
	if ((vpd[PDX(ova)] & PTE_P) && (vpt[VPN(ova)] & PTE_P))
  801792:	89 da                	mov    %ebx,%edx
  801794:	89 d8                	mov    %ebx,%eax
  801796:	c1 e8 16             	shr    $0x16,%eax
  801799:	8b 04 85 00 d0 7b ef 	mov    -0x10843000(,%eax,4),%eax
  8017a0:	a8 01                	test   $0x1,%al
  8017a2:	74 43                	je     8017e7 <dup+0xac>
  8017a4:	c1 ea 0c             	shr    $0xc,%edx
  8017a7:	8b 04 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%eax
  8017ae:	a8 01                	test   $0x1,%al
  8017b0:	74 35                	je     8017e7 <dup+0xac>
		if ((r = sys_page_map(0, ova, 0, nva, (vpt[VPN(ova)]) & PTE_USER)) < 0)
  8017b2:	8b 04 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%eax
  8017b9:	25 07 0e 00 00       	and    $0xe07,%eax
  8017be:	89 44 24 10          	mov    %eax,0x10(%esp)
  8017c2:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  8017c5:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8017c9:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  8017d0:	00 
  8017d1:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8017d5:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8017dc:	e8 77 f8 ff ff       	call   801058 <sys_page_map>
  8017e1:	89 c3                	mov    %eax,%ebx
  8017e3:	85 c0                	test   %eax,%eax
  8017e5:	78 3f                	js     801826 <dup+0xeb>
			goto err;
	if ((r = sys_page_map(0, oldfd, 0, newfd, (vpt[VPN(oldfd)]) & PTE_USER)) < 0)
  8017e7:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8017ea:	89 c2                	mov    %eax,%edx
  8017ec:	c1 ea 0c             	shr    $0xc,%edx
  8017ef:	8b 14 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%edx
  8017f6:	81 e2 07 0e 00 00    	and    $0xe07,%edx
  8017fc:	89 54 24 10          	mov    %edx,0x10(%esp)
  801800:	89 74 24 0c          	mov    %esi,0xc(%esp)
  801804:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  80180b:	00 
  80180c:	89 44 24 04          	mov    %eax,0x4(%esp)
  801810:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801817:	e8 3c f8 ff ff       	call   801058 <sys_page_map>
  80181c:	89 c3                	mov    %eax,%ebx
  80181e:	85 c0                	test   %eax,%eax
  801820:	78 04                	js     801826 <dup+0xeb>
  801822:	89 fb                	mov    %edi,%ebx
  801824:	eb 23                	jmp    801849 <dup+0x10e>
		goto err;

	return newfdnum;
err:
	sys_page_unmap(0, newfd);
  801826:	89 74 24 04          	mov    %esi,0x4(%esp)
  80182a:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801831:	e8 c4 f7 ff ff       	call   800ffa <sys_page_unmap>
	sys_page_unmap(0, nva);
  801836:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  801839:	89 44 24 04          	mov    %eax,0x4(%esp)
  80183d:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801844:	e8 b1 f7 ff ff       	call   800ffa <sys_page_unmap>
	return r;
}
  801849:	89 d8                	mov    %ebx,%eax
  80184b:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  80184e:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801851:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801854:	89 ec                	mov    %ebp,%esp
  801856:	5d                   	pop    %ebp
  801857:	c3                   	ret    

00801858 <fsipc>:
// type: request code, passed as the simple integer IPC value.
// dstva: virtual address at which to receive reply page, 0 if none.
// Returns result from the file server.
static int
fsipc(unsigned type, void *dstva)
{
  801858:	55                   	push   %ebp
  801859:	89 e5                	mov    %esp,%ebp
  80185b:	53                   	push   %ebx
  80185c:	83 ec 14             	sub    $0x14,%esp
  80185f:	89 d3                	mov    %edx,%ebx
	if (debug)
		cprintf("[%08x] fsipc %d %08x\n", env->env_id, type, *(uint32_t *)&fsipcbuf);

	ipc_send(envs[1].env_id, type, &fsipcbuf, PTE_P | PTE_W | PTE_U);
  801861:	8b 15 c8 00 c0 ee    	mov    0xeec000c8,%edx
  801867:	c7 44 24 0c 07 00 00 	movl   $0x7,0xc(%esp)
  80186e:	00 
  80186f:	c7 44 24 08 00 40 80 	movl   $0x804000,0x8(%esp)
  801876:	00 
  801877:	89 44 24 04          	mov    %eax,0x4(%esp)
  80187b:	89 14 24             	mov    %edx,(%esp)
  80187e:	e8 2d 13 00 00       	call   802bb0 <ipc_send>
	return ipc_recv(NULL, dstva, NULL);
  801883:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  80188a:	00 
  80188b:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  80188f:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801896:	e8 87 13 00 00       	call   802c22 <ipc_recv>
}
  80189b:	83 c4 14             	add    $0x14,%esp
  80189e:	5b                   	pop    %ebx
  80189f:	5d                   	pop    %ebp
  8018a0:	c3                   	ret    

008018a1 <devfile_trunc>:
}

// Truncate or extend an open file to 'size' bytes
static int
devfile_trunc(struct Fd *fd, off_t newsize)
{
  8018a1:	55                   	push   %ebp
  8018a2:	89 e5                	mov    %esp,%ebp
  8018a4:	83 ec 08             	sub    $0x8,%esp
	fsipcbuf.set_size.req_fileid = fd->fd_file.id;
  8018a7:	8b 45 08             	mov    0x8(%ebp),%eax
  8018aa:	8b 40 0c             	mov    0xc(%eax),%eax
  8018ad:	a3 00 40 80 00       	mov    %eax,0x804000
	fsipcbuf.set_size.req_size = newsize;
  8018b2:	8b 45 0c             	mov    0xc(%ebp),%eax
  8018b5:	a3 04 40 80 00       	mov    %eax,0x804004
	return fsipc(FSREQ_SET_SIZE, NULL);
  8018ba:	ba 00 00 00 00       	mov    $0x0,%edx
  8018bf:	b8 02 00 00 00       	mov    $0x2,%eax
  8018c4:	e8 8f ff ff ff       	call   801858 <fsipc>
}
  8018c9:	c9                   	leave  
  8018ca:	c3                   	ret    

008018cb <devfile_flush>:
// open, unmapping it is enough to free up server-side resources.
// Other than that, we just have to make sure our changes are flushed
// to disk.
static int
devfile_flush(struct Fd *fd)
{
  8018cb:	55                   	push   %ebp
  8018cc:	89 e5                	mov    %esp,%ebp
  8018ce:	83 ec 08             	sub    $0x8,%esp
	fsipcbuf.flush.req_fileid = fd->fd_file.id;
  8018d1:	8b 45 08             	mov    0x8(%ebp),%eax
  8018d4:	8b 40 0c             	mov    0xc(%eax),%eax
  8018d7:	a3 00 40 80 00       	mov    %eax,0x804000
	return fsipc(FSREQ_FLUSH, NULL);
  8018dc:	ba 00 00 00 00       	mov    $0x0,%edx
  8018e1:	b8 06 00 00 00       	mov    $0x6,%eax
  8018e6:	e8 6d ff ff ff       	call   801858 <fsipc>
}
  8018eb:	c9                   	leave  
  8018ec:	c3                   	ret    

008018ed <sync>:
}

// Synchronize disk with buffer cache
int
sync(void)
{
  8018ed:	55                   	push   %ebp
  8018ee:	89 e5                	mov    %esp,%ebp
  8018f0:	83 ec 08             	sub    $0x8,%esp
	// Ask the file server to update the disk
	// by writing any dirty blocks in the buffer cache.

	return fsipc(FSREQ_SYNC, NULL);
  8018f3:	ba 00 00 00 00       	mov    $0x0,%edx
  8018f8:	b8 08 00 00 00       	mov    $0x8,%eax
  8018fd:	e8 56 ff ff ff       	call   801858 <fsipc>
}
  801902:	c9                   	leave  
  801903:	c3                   	ret    

00801904 <devfile_stat>:
    return n;
}

static int
devfile_stat(struct Fd *fd, struct Stat *st)
{
  801904:	55                   	push   %ebp
  801905:	89 e5                	mov    %esp,%ebp
  801907:	53                   	push   %ebx
  801908:	83 ec 14             	sub    $0x14,%esp
  80190b:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int r;

	fsipcbuf.stat.req_fileid = fd->fd_file.id;
  80190e:	8b 45 08             	mov    0x8(%ebp),%eax
  801911:	8b 40 0c             	mov    0xc(%eax),%eax
  801914:	a3 00 40 80 00       	mov    %eax,0x804000
	if ((r = fsipc(FSREQ_STAT, NULL)) < 0)
  801919:	ba 00 00 00 00       	mov    $0x0,%edx
  80191e:	b8 05 00 00 00       	mov    $0x5,%eax
  801923:	e8 30 ff ff ff       	call   801858 <fsipc>
  801928:	85 c0                	test   %eax,%eax
  80192a:	78 2b                	js     801957 <devfile_stat+0x53>
		return r;
	strcpy(st->st_name, fsipcbuf.statRet.ret_name);
  80192c:	c7 44 24 04 00 40 80 	movl   $0x804000,0x4(%esp)
  801933:	00 
  801934:	89 1c 24             	mov    %ebx,(%esp)
  801937:	e8 1e f0 ff ff       	call   80095a <strcpy>
	st->st_size = fsipcbuf.statRet.ret_size;
  80193c:	a1 80 40 80 00       	mov    0x804080,%eax
  801941:	89 83 80 00 00 00    	mov    %eax,0x80(%ebx)
	st->st_isdir = fsipcbuf.statRet.ret_isdir;
  801947:	a1 84 40 80 00       	mov    0x804084,%eax
  80194c:	89 83 84 00 00 00    	mov    %eax,0x84(%ebx)
  801952:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
}
  801957:	83 c4 14             	add    $0x14,%esp
  80195a:	5b                   	pop    %ebx
  80195b:	5d                   	pop    %ebp
  80195c:	c3                   	ret    

0080195d <devfile_write>:
// Returns:
//	 The number of bytes successfully written.
//	 < 0 on error.
static ssize_t
devfile_write(struct Fd *fd, const void *buf, size_t n)
{
  80195d:	55                   	push   %ebp
  80195e:	89 e5                	mov    %esp,%ebp
  801960:	53                   	push   %ebx
  801961:	83 ec 14             	sub    $0x14,%esp
  801964:	8b 45 08             	mov    0x8(%ebp),%eax
  801967:	8b 55 0c             	mov    0xc(%ebp),%edx
  80196a:	8b 5d 10             	mov    0x10(%ebp),%ebx
	// careful: fsipcbuf.write.req_buf is only so large, but
	// remember that write is always allowed to write *fewer*
	// bytes than requested.
	// LAB 5: Your code here
    int r;
    if (!fd || !buf || (n>(PGSIZE-sizeof(size_t)-sizeof(int))))
  80196d:	85 c0                	test   %eax,%eax
  80196f:	74 44                	je     8019b5 <devfile_write+0x58>
  801971:	85 d2                	test   %edx,%edx
  801973:	74 40                	je     8019b5 <devfile_write+0x58>
  801975:	81 fb f8 0f 00 00    	cmp    $0xff8,%ebx
  80197b:	77 38                	ja     8019b5 <devfile_write+0x58>
        return -E_INVAL;

    fsipcbuf.write.req_fileid   = fd->fd_file.id;
  80197d:	8b 40 0c             	mov    0xc(%eax),%eax
  801980:	a3 00 40 80 00       	mov    %eax,0x804000
    fsipcbuf.write.req_n        = n;
  801985:	89 1d 04 40 80 00    	mov    %ebx,0x804004
    memmove(fsipcbuf.write.req_buf, buf, n);
  80198b:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  80198f:	89 54 24 04          	mov    %edx,0x4(%esp)
  801993:	c7 04 24 08 40 80 00 	movl   $0x804008,(%esp)
  80199a:	e8 76 f1 ff ff       	call   800b15 <memmove>
    if ((r=fsipc(FSREQ_WRITE, NULL))<0)
  80199f:	ba 00 00 00 00       	mov    $0x0,%edx
  8019a4:	b8 04 00 00 00       	mov    $0x4,%eax
  8019a9:	e8 aa fe ff ff       	call   801858 <fsipc>
        return r;
    return n;
  8019ae:	85 c0                	test   %eax,%eax
  8019b0:	0f 49 c3             	cmovns %ebx,%eax
  8019b3:	eb 05                	jmp    8019ba <devfile_write+0x5d>
  8019b5:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
}
  8019ba:	83 c4 14             	add    $0x14,%esp
  8019bd:	5b                   	pop    %ebx
  8019be:	5d                   	pop    %ebp
  8019bf:	c3                   	ret    

008019c0 <devfile_read>:
// Returns:
// 	The number of bytes successfully read.
// 	< 0 on error.
static ssize_t
devfile_read(struct Fd *fd, void *buf, size_t n)
{
  8019c0:	55                   	push   %ebp
  8019c1:	89 e5                	mov    %esp,%ebp
  8019c3:	83 ec 18             	sub    $0x18,%esp
  8019c6:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  8019c9:	89 75 fc             	mov    %esi,-0x4(%ebp)
  8019cc:	8b 45 08             	mov    0x8(%ebp),%eax
  8019cf:	8b 75 0c             	mov    0xc(%ebp),%esi
	// filling fsipcbuf.read with the request arguments.  The
	// bytes read will be written back to fsipcbuf by the file
	// system server.
	// LAB 5: Your code here
  int r;
  if (!fd || !buf)
  8019d2:	85 c0                	test   %eax,%eax
  8019d4:	74 04                	je     8019da <devfile_read+0x1a>
  8019d6:	85 f6                	test   %esi,%esi
  8019d8:	75 07                	jne    8019e1 <devfile_read+0x21>
  8019da:	bb fd ff ff ff       	mov    $0xfffffffd,%ebx
  8019df:	eb 39                	jmp    801a1a <devfile_read+0x5a>
    return -E_INVAL;

  fsipcbuf.read.req_fileid    = fd->fd_file.id;
  8019e1:	8b 40 0c             	mov    0xc(%eax),%eax
  8019e4:	a3 00 40 80 00       	mov    %eax,0x804000
  fsipcbuf.read.req_n         = n;
  8019e9:	8b 45 10             	mov    0x10(%ebp),%eax
  8019ec:	a3 04 40 80 00       	mov    %eax,0x804004
  if ((r=fsipc(FSREQ_READ, NULL))<0)
  8019f1:	ba 00 00 00 00       	mov    $0x0,%edx
  8019f6:	b8 03 00 00 00       	mov    $0x3,%eax
  8019fb:	e8 58 fe ff ff       	call   801858 <fsipc>
  801a00:	89 c3                	mov    %eax,%ebx
  801a02:	85 c0                	test   %eax,%eax
  801a04:	78 14                	js     801a1a <devfile_read+0x5a>
    return r;

  memmove(buf, fsipcbuf.readRet.ret_buf, r);
  801a06:	89 44 24 08          	mov    %eax,0x8(%esp)
  801a0a:	c7 44 24 04 00 40 80 	movl   $0x804000,0x4(%esp)
  801a11:	00 
  801a12:	89 34 24             	mov    %esi,(%esp)
  801a15:	e8 fb f0 ff ff       	call   800b15 <memmove>
  return r;
}
  801a1a:	89 d8                	mov    %ebx,%eax
  801a1c:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  801a1f:	8b 75 fc             	mov    -0x4(%ebp),%esi
  801a22:	89 ec                	mov    %ebp,%esp
  801a24:	5d                   	pop    %ebp
  801a25:	c3                   	ret    

00801a26 <remove>:
}

// Delete a file
int
remove(const char *path)
{
  801a26:	55                   	push   %ebp
  801a27:	89 e5                	mov    %esp,%ebp
  801a29:	53                   	push   %ebx
  801a2a:	83 ec 14             	sub    $0x14,%esp
  801a2d:	8b 5d 08             	mov    0x8(%ebp),%ebx
	if (strlen(path) >= MAXPATHLEN)
  801a30:	89 1c 24             	mov    %ebx,(%esp)
  801a33:	e8 d8 ee ff ff       	call   800910 <strlen>
  801a38:	89 c2                	mov    %eax,%edx
  801a3a:	b8 f4 ff ff ff       	mov    $0xfffffff4,%eax
  801a3f:	81 fa ff 03 00 00    	cmp    $0x3ff,%edx
  801a45:	7f 1f                	jg     801a66 <remove+0x40>
		return -E_BAD_PATH;
	strcpy(fsipcbuf.remove.req_path, path);
  801a47:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  801a4b:	c7 04 24 00 40 80 00 	movl   $0x804000,(%esp)
  801a52:	e8 03 ef ff ff       	call   80095a <strcpy>
	return fsipc(FSREQ_REMOVE, NULL);
  801a57:	ba 00 00 00 00       	mov    $0x0,%edx
  801a5c:	b8 07 00 00 00       	mov    $0x7,%eax
  801a61:	e8 f2 fd ff ff       	call   801858 <fsipc>
}
  801a66:	83 c4 14             	add    $0x14,%esp
  801a69:	5b                   	pop    %ebx
  801a6a:	5d                   	pop    %ebp
  801a6b:	c3                   	ret    

00801a6c <open>:
// 	The file descriptor index on success
// 	-E_BAD_PATH if the path is too long (>= MAXPATHLEN)
// 	< 0 for other errors.
int
open(const char *path, int mode)
{
  801a6c:	55                   	push   %ebp
  801a6d:	89 e5                	mov    %esp,%ebp
  801a6f:	83 ec 28             	sub    $0x28,%esp
  801a72:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  801a75:	89 75 fc             	mov    %esi,-0x4(%ebp)
  801a78:	8b 75 08             	mov    0x8(%ebp),%esi
	// Return the file descriptor index.
	// If any step after fd_alloc fails, use fd_close to free the
  struct Fd *f    = NULL;
  int r   = 0;

  if (!path)
  801a7b:	bb fd ff ff ff       	mov    $0xfffffffd,%ebx
  801a80:	85 f6                	test   %esi,%esi
  801a82:	74 65                	je     801ae9 <open+0x7d>
	// (fd_alloc does not allocate a page, it just returns an
	// unused fd address.  Do you need to allocate a page?)
	//
	// Return the file descriptor index.
	// If any step after fd_alloc fails, use fd_close to free the
  struct Fd *f    = NULL;
  801a84:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)
  int r   = 0;

  if (!path)
    return -E_INVAL;
  if((r=fd_alloc(&f))<0)
  801a8b:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801a8e:	89 04 24             	mov    %eax,(%esp)
  801a91:	e8 75 f7 ff ff       	call   80120b <fd_alloc>
  801a96:	89 c3                	mov    %eax,%ebx
  801a98:	85 c0                	test   %eax,%eax
  801a9a:	78 4d                	js     801ae9 <open+0x7d>
    return r;

	strcpy(fsipcbuf.open.req_path, path);
  801a9c:	89 74 24 04          	mov    %esi,0x4(%esp)
  801aa0:	c7 04 24 00 40 80 00 	movl   $0x804000,(%esp)
  801aa7:	e8 ae ee ff ff       	call   80095a <strcpy>
	fsipcbuf.open.req_omode = mode;
  801aac:	8b 45 0c             	mov    0xc(%ebp),%eax
  801aaf:	a3 00 44 80 00       	mov    %eax,0x804400

  if ((r=fsipc(FSREQ_OPEN, f))<0) {
  801ab4:	8b 55 f4             	mov    -0xc(%ebp),%edx
  801ab7:	b8 01 00 00 00       	mov    $0x1,%eax
  801abc:	e8 97 fd ff ff       	call   801858 <fsipc>
  801ac1:	89 c3                	mov    %eax,%ebx
  801ac3:	85 c0                	test   %eax,%eax
  801ac5:	79 15                	jns    801adc <open+0x70>
    fd_close(f, 0);
  801ac7:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  801ace:	00 
  801acf:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801ad2:	89 04 24             	mov    %eax,(%esp)
  801ad5:	e8 3a fb ff ff       	call   801614 <fd_close>
    return r;
  801ada:	eb 0d                	jmp    801ae9 <open+0x7d>
  }
  return fd2num(f);
  801adc:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801adf:	89 04 24             	mov    %eax,(%esp)
  801ae2:	e8 f9 f6 ff ff       	call   8011e0 <fd2num>
  801ae7:	89 c3                	mov    %eax,%ebx
}
  801ae9:	89 d8                	mov    %ebx,%eax
  801aeb:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  801aee:	8b 75 fc             	mov    -0x4(%ebp),%esi
  801af1:	89 ec                	mov    %ebp,%esp
  801af3:	5d                   	pop    %ebp
  801af4:	c3                   	ret    
  801af5:	00 00                	add    %al,(%eax)
	...

00801af8 <spawn>:
// argv: pointer to null-terminated array of pointers to strings,
// 	 which will be passed to the child as its command-line arguments.
// Returns child envid on success, < 0 on failure.
int
spawn(const char *prog, const char **argv)
{
  801af8:	55                   	push   %ebp
  801af9:	89 e5                	mov    %esp,%ebp
  801afb:	57                   	push   %edi
  801afc:	56                   	push   %esi
  801afd:	53                   	push   %ebx
  801afe:	81 ec 9c 02 00 00    	sub    $0x29c,%esp
	//   - Call sys_env_set_trapframe(child, &child_tf) to set up the
	//     correct initial eip and esp values in the child.
	//
	//   - Start the child process running with sys_env_set_status().

	if ((r = open(prog, O_RDONLY)) < 0)
  801b04:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  801b0b:	00 
  801b0c:	8b 45 08             	mov    0x8(%ebp),%eax
  801b0f:	89 04 24             	mov    %eax,(%esp)
  801b12:	e8 55 ff ff ff       	call   801a6c <open>
  801b17:	89 85 88 fd ff ff    	mov    %eax,-0x278(%ebp)
  801b1d:	89 c3                	mov    %eax,%ebx
  801b1f:	85 c0                	test   %eax,%eax
  801b21:	0f 88 e0 05 00 00    	js     802107 <spawn+0x60f>
	fd = r;

	// Read elf header
	elf = (struct Elf*) elf_buf;
	if (read(fd, elf_buf, sizeof(elf_buf)) != sizeof(elf_buf)
	    || elf->e_magic != ELF_MAGIC) {
  801b27:	c7 44 24 08 00 02 00 	movl   $0x200,0x8(%esp)
  801b2e:	00 
  801b2f:	8d 85 e8 fd ff ff    	lea    -0x218(%ebp),%eax
  801b35:	89 44 24 04          	mov    %eax,0x4(%esp)
  801b39:	89 1c 24             	mov    %ebx,(%esp)
  801b3c:	e8 a2 f9 ff ff       	call   8014e3 <read>
		return r;
	fd = r;

	// Read elf header
	elf = (struct Elf*) elf_buf;
	if (read(fd, elf_buf, sizeof(elf_buf)) != sizeof(elf_buf)
  801b41:	3d 00 02 00 00       	cmp    $0x200,%eax
  801b46:	75 0c                	jne    801b54 <spawn+0x5c>
	    || elf->e_magic != ELF_MAGIC) {
  801b48:	81 bd e8 fd ff ff 7f 	cmpl   $0x464c457f,-0x218(%ebp)
  801b4f:	45 4c 46 
  801b52:	74 36                	je     801b8a <spawn+0x92>
		close(fd);
  801b54:	8b 85 88 fd ff ff    	mov    -0x278(%ebp),%eax
  801b5a:	89 04 24             	mov    %eax,(%esp)
  801b5d:	e8 3a fb ff ff       	call   80169c <close>
		cprintf("elf magic %08x want %08x\n", elf->e_magic, ELF_MAGIC);
  801b62:	c7 44 24 08 7f 45 4c 	movl   $0x464c457f,0x8(%esp)
  801b69:	46 
  801b6a:	8b 85 e8 fd ff ff    	mov    -0x218(%ebp),%eax
  801b70:	89 44 24 04          	mov    %eax,0x4(%esp)
  801b74:	c7 04 24 08 34 80 00 	movl   $0x803408,(%esp)
  801b7b:	e8 0d e7 ff ff       	call   80028d <cprintf>
  801b80:	bb f2 ff ff ff       	mov    $0xfffffff2,%ebx
		return -E_NOT_EXEC;
  801b85:	e9 7d 05 00 00       	jmp    802107 <spawn+0x60f>
static __inline envid_t sys_exofork(void) __attribute__((always_inline));
static __inline envid_t
sys_exofork(void)
{
	envid_t ret;
	__asm __volatile("int %2"
  801b8a:	ba 07 00 00 00       	mov    $0x7,%edx
  801b8f:	89 d0                	mov    %edx,%eax
  801b91:	cd 30                	int    $0x30
  801b93:	89 85 84 fd ff ff    	mov    %eax,-0x27c(%ebp)
	}

	// Create new child environment
	if ((r = sys_exofork()) < 0)
  801b99:	85 c0                	test   %eax,%eax
  801b9b:	0f 88 60 05 00 00    	js     802101 <spawn+0x609>
		return r;
	child = r;

	// Set up trap frame, including initial stack.
	child_tf = envs[ENVX(child)].env_tf;
  801ba1:	89 c6                	mov    %eax,%esi
  801ba3:	81 e6 ff 03 00 00    	and    $0x3ff,%esi
  801ba9:	6b f6 7c             	imul   $0x7c,%esi,%esi
  801bac:	8d bd a4 fd ff ff    	lea    -0x25c(%ebp),%edi
  801bb2:	81 c6 00 00 c0 ee    	add    $0xeec00000,%esi
  801bb8:	b9 11 00 00 00       	mov    $0x11,%ecx
  801bbd:	f3 a5                	rep movsl %ds:(%esi),%es:(%edi)
	child_tf.tf_eip = elf->e_entry;
  801bbf:	8b 85 00 fe ff ff    	mov    -0x200(%ebp),%eax
  801bc5:	89 85 d4 fd ff ff    	mov    %eax,-0x22c(%ebp)
	uintptr_t *argv_store;

	// Count the number of arguments (argc)
	// and the total amount of space needed for strings (string_size).
	string_size = 0;
	for (argc = 0; argv[argc] != 0; argc++)
  801bcb:	8b 55 0c             	mov    0xc(%ebp),%edx
  801bce:	8b 02                	mov    (%edx),%eax
  801bd0:	bb 00 00 00 00       	mov    $0x0,%ebx
  801bd5:	be 00 00 00 00       	mov    $0x0,%esi
  801bda:	85 c0                	test   %eax,%eax
  801bdc:	75 16                	jne    801bf4 <spawn+0xfc>
  801bde:	c7 85 7c fd ff ff 00 	movl   $0x0,-0x284(%ebp)
  801be5:	00 00 00 
  801be8:	c7 85 78 fd ff ff 00 	movl   $0x0,-0x288(%ebp)
  801bef:	00 00 00 
  801bf2:	eb 2c                	jmp    801c20 <spawn+0x128>
  801bf4:	8b 7d 0c             	mov    0xc(%ebp),%edi
		string_size += strlen(argv[argc]) + 1;
  801bf7:	89 04 24             	mov    %eax,(%esp)
  801bfa:	e8 11 ed ff ff       	call   800910 <strlen>
  801bff:	8d 5c 18 01          	lea    0x1(%eax,%ebx,1),%ebx
	uintptr_t *argv_store;

	// Count the number of arguments (argc)
	// and the total amount of space needed for strings (string_size).
	string_size = 0;
	for (argc = 0; argv[argc] != 0; argc++)
  801c03:	83 c6 01             	add    $0x1,%esi
  801c06:	8d 14 b5 00 00 00 00 	lea    0x0(,%esi,4),%edx
  801c0d:	8b 04 b7             	mov    (%edi,%esi,4),%eax
  801c10:	85 c0                	test   %eax,%eax
  801c12:	75 e3                	jne    801bf7 <spawn+0xff>
  801c14:	89 95 7c fd ff ff    	mov    %edx,-0x284(%ebp)
  801c1a:	89 b5 78 fd ff ff    	mov    %esi,-0x288(%ebp)
	// Determine where to place the strings and the argv array.
	// Set up pointers into the temporary page 'UTEMP'; we'll map a page
	// there later, then remap that page into the child environment
	// at (USTACKTOP - PGSIZE).
	// strings is the topmost thing on the stack.
	string_store = (char*) UTEMP + PGSIZE - string_size;
  801c20:	f7 db                	neg    %ebx
  801c22:	8d bb 00 10 40 00    	lea    0x401000(%ebx),%edi
	// argv is below that.  There's one argument pointer per argument, plus
	// a null pointer.
	argv_store = (uintptr_t*) (ROUNDDOWN(string_store, 4) - 4 * (argc + 1));
  801c28:	89 fa                	mov    %edi,%edx
  801c2a:	83 e2 fc             	and    $0xfffffffc,%edx
  801c2d:	89 f0                	mov    %esi,%eax
  801c2f:	f7 d0                	not    %eax
  801c31:	8d 04 82             	lea    (%edx,%eax,4),%eax
  801c34:	89 85 94 fd ff ff    	mov    %eax,-0x26c(%ebp)
	
	// Make sure that argv, strings, and the 2 words that hold 'argc'
	// and 'argv' themselves will all fit in a single stack page.
	if ((void*) (argv_store - 2) < (void*) UTEMP)
  801c3a:	83 e8 08             	sub    $0x8,%eax
  801c3d:	89 85 80 fd ff ff    	mov    %eax,-0x280(%ebp)
	return child;

error:
	sys_env_destroy(child);
	close(fd);
	return r;
  801c43:	bb fc ff ff ff       	mov    $0xfffffffc,%ebx
	// a null pointer.
	argv_store = (uintptr_t*) (ROUNDDOWN(string_store, 4) - 4 * (argc + 1));
	
	// Make sure that argv, strings, and the 2 words that hold 'argc'
	// and 'argv' themselves will all fit in a single stack page.
	if ((void*) (argv_store - 2) < (void*) UTEMP)
  801c48:	3d ff ff 3f 00       	cmp    $0x3fffff,%eax
  801c4d:	0f 86 b4 04 00 00    	jbe    802107 <spawn+0x60f>
		return -E_NO_MEM;

	// Allocate the single stack page at UTEMP.
	if ((r = sys_page_alloc(0, (void*) UTEMP, PTE_P|PTE_U|PTE_W)) < 0)
  801c53:	c7 44 24 08 07 00 00 	movl   $0x7,0x8(%esp)
  801c5a:	00 
  801c5b:	c7 44 24 04 00 00 40 	movl   $0x400000,0x4(%esp)
  801c62:	00 
  801c63:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801c6a:	e8 47 f4 ff ff       	call   8010b6 <sys_page_alloc>
  801c6f:	89 c3                	mov    %eax,%ebx
  801c71:	85 c0                	test   %eax,%eax
  801c73:	0f 88 8e 04 00 00    	js     802107 <spawn+0x60f>
	//	  (Again, argv should use an address valid in the child's
	//	  environment.)
	//
	//	* Set *init_esp to the initial stack pointer for the child,
	//	  (Again, use an address valid in the child's environment.)
	for (i = 0; i < argc; i++) {
  801c79:	85 f6                	test   %esi,%esi
  801c7b:	7e 46                	jle    801cc3 <spawn+0x1cb>
  801c7d:	bb 00 00 00 00       	mov    $0x0,%ebx
  801c82:	89 b5 8c fd ff ff    	mov    %esi,-0x274(%ebp)
  801c88:	8b 75 0c             	mov    0xc(%ebp),%esi
		argv_store[i] = UTEMP2USTACK(string_store);
  801c8b:	8d 87 00 d0 7f ee    	lea    -0x11803000(%edi),%eax
  801c91:	8b 95 94 fd ff ff    	mov    -0x26c(%ebp),%edx
  801c97:	89 04 9a             	mov    %eax,(%edx,%ebx,4)
		strcpy(string_store, argv[i]);
  801c9a:	8b 04 9e             	mov    (%esi,%ebx,4),%eax
  801c9d:	89 44 24 04          	mov    %eax,0x4(%esp)
  801ca1:	89 3c 24             	mov    %edi,(%esp)
  801ca4:	e8 b1 ec ff ff       	call   80095a <strcpy>
		string_store += strlen(argv[i]) + 1;
  801ca9:	8b 04 9e             	mov    (%esi,%ebx,4),%eax
  801cac:	89 04 24             	mov    %eax,(%esp)
  801caf:	e8 5c ec ff ff       	call   800910 <strlen>
  801cb4:	8d 7c 38 01          	lea    0x1(%eax,%edi,1),%edi
	//	  (Again, argv should use an address valid in the child's
	//	  environment.)
	//
	//	* Set *init_esp to the initial stack pointer for the child,
	//	  (Again, use an address valid in the child's environment.)
	for (i = 0; i < argc; i++) {
  801cb8:	83 c3 01             	add    $0x1,%ebx
  801cbb:	3b 9d 8c fd ff ff    	cmp    -0x274(%ebp),%ebx
  801cc1:	7c c8                	jl     801c8b <spawn+0x193>
		argv_store[i] = UTEMP2USTACK(string_store);
		strcpy(string_store, argv[i]);
		string_store += strlen(argv[i]) + 1;
	}
	argv_store[argc] = 0;
  801cc3:	8b 95 94 fd ff ff    	mov    -0x26c(%ebp),%edx
  801cc9:	8b 85 7c fd ff ff    	mov    -0x284(%ebp),%eax
  801ccf:	c7 04 02 00 00 00 00 	movl   $0x0,(%edx,%eax,1)
	assert(string_store == (char*)UTEMP + PGSIZE);
  801cd6:	81 ff 00 10 40 00    	cmp    $0x401000,%edi
  801cdc:	74 24                	je     801d02 <spawn+0x20a>
  801cde:	c7 44 24 0c a8 34 80 	movl   $0x8034a8,0xc(%esp)
  801ce5:	00 
  801ce6:	c7 44 24 08 22 34 80 	movl   $0x803422,0x8(%esp)
  801ced:	00 
  801cee:	c7 44 24 04 d9 00 00 	movl   $0xd9,0x4(%esp)
  801cf5:	00 
  801cf6:	c7 04 24 37 34 80 00 	movl   $0x803437,(%esp)
  801cfd:	e8 c6 e4 ff ff       	call   8001c8 <_panic>

	argv_store[-1] = UTEMP2USTACK(argv_store);
  801d02:	8b 85 94 fd ff ff    	mov    -0x26c(%ebp),%eax
  801d08:	2d 00 30 80 11       	sub    $0x11803000,%eax
  801d0d:	8b 95 94 fd ff ff    	mov    -0x26c(%ebp),%edx
  801d13:	89 42 fc             	mov    %eax,-0x4(%edx)
	argv_store[-2] = argc;
  801d16:	8b 95 78 fd ff ff    	mov    -0x288(%ebp),%edx
  801d1c:	8b 85 80 fd ff ff    	mov    -0x280(%ebp),%eax
  801d22:	89 10                	mov    %edx,(%eax)

	*init_esp = UTEMP2USTACK(&argv_store[-2]);
  801d24:	8b 85 94 fd ff ff    	mov    -0x26c(%ebp),%eax
  801d2a:	2d 08 30 80 11       	sub    $0x11803008,%eax
  801d2f:	89 85 e0 fd ff ff    	mov    %eax,-0x220(%ebp)

	// After completing the stack, map it into the child's address space
	// and unmap it from ours!
	if ((r = sys_page_map(0, UTEMP, child, (void*) (USTACKTOP - PGSIZE), PTE_P | PTE_U | PTE_W)) < 0)
  801d35:	c7 44 24 10 07 00 00 	movl   $0x7,0x10(%esp)
  801d3c:	00 
  801d3d:	c7 44 24 0c 00 d0 bf 	movl   $0xeebfd000,0xc(%esp)
  801d44:	ee 
  801d45:	8b 85 84 fd ff ff    	mov    -0x27c(%ebp),%eax
  801d4b:	89 44 24 08          	mov    %eax,0x8(%esp)
  801d4f:	c7 44 24 04 00 00 40 	movl   $0x400000,0x4(%esp)
  801d56:	00 
  801d57:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801d5e:	e8 f5 f2 ff ff       	call   801058 <sys_page_map>
  801d63:	89 c3                	mov    %eax,%ebx
  801d65:	85 c0                	test   %eax,%eax
  801d67:	78 1a                	js     801d83 <spawn+0x28b>
		goto error;
	if ((r = sys_page_unmap(0, UTEMP)) < 0)
  801d69:	c7 44 24 04 00 00 40 	movl   $0x400000,0x4(%esp)
  801d70:	00 
  801d71:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801d78:	e8 7d f2 ff ff       	call   800ffa <sys_page_unmap>
  801d7d:	89 c3                	mov    %eax,%ebx
  801d7f:	85 c0                	test   %eax,%eax
  801d81:	79 19                	jns    801d9c <spawn+0x2a4>
		goto error;

	return 0;

error:
	sys_page_unmap(0, UTEMP);
  801d83:	c7 44 24 04 00 00 40 	movl   $0x400000,0x4(%esp)
  801d8a:	00 
  801d8b:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801d92:	e8 63 f2 ff ff       	call   800ffa <sys_page_unmap>
  801d97:	e9 6b 03 00 00       	jmp    802107 <spawn+0x60f>

	if ((r = init_stack(child, argv, &child_tf.tf_esp)) < 0)
		return r;

	// Set up program segments as defined in ELF header.
	ph = (struct Proghdr*) (elf_buf + elf->e_phoff);
  801d9c:	8b 85 04 fe ff ff    	mov    -0x1fc(%ebp),%eax
	for (i = 0; i < elf->e_phnum; i++, ph++) {
  801da2:	66 83 bd 14 fe ff ff 	cmpw   $0x0,-0x1ec(%ebp)
  801da9:	00 
  801daa:	0f 84 e4 01 00 00    	je     801f94 <spawn+0x49c>

	if ((r = init_stack(child, argv, &child_tf.tf_esp)) < 0)
		return r;

	// Set up program segments as defined in ELF header.
	ph = (struct Proghdr*) (elf_buf + elf->e_phoff);
  801db0:	8d 84 05 e8 fd ff ff 	lea    -0x218(%ebp,%eax,1),%eax
  801db7:	89 85 80 fd ff ff    	mov    %eax,-0x280(%ebp)
  801dbd:	c7 85 7c fd ff ff 00 	movl   $0x0,-0x284(%ebp)
  801dc4:	00 00 00 
	for (i = 0; i < elf->e_phnum; i++, ph++) {
		if (ph->p_type != ELF_PROG_LOAD)
  801dc7:	8b 95 80 fd ff ff    	mov    -0x280(%ebp),%edx
  801dcd:	83 3a 01             	cmpl   $0x1,(%edx)
  801dd0:	0f 85 9c 01 00 00    	jne    801f72 <spawn+0x47a>
			continue;
		perm = PTE_P | PTE_U;
		if (ph->p_flags & ELF_PROG_FLAG_WRITE)
  801dd6:	8b 42 18             	mov    0x18(%edx),%eax
  801dd9:	83 e0 02             	and    $0x2,%eax
  801ddc:	83 f8 01             	cmp    $0x1,%eax
  801ddf:	19 c0                	sbb    %eax,%eax
  801de1:	83 e0 fe             	and    $0xfffffffe,%eax
  801de4:	83 c0 07             	add    $0x7,%eax
  801de7:	89 85 94 fd ff ff    	mov    %eax,-0x26c(%ebp)
			perm |= PTE_W;
		if ((r = map_segment(child, ph->p_va, ph->p_memsz, 
  801ded:	8b 52 04             	mov    0x4(%edx),%edx
  801df0:	89 95 78 fd ff ff    	mov    %edx,-0x288(%ebp)
  801df6:	8b 85 80 fd ff ff    	mov    -0x280(%ebp),%eax
  801dfc:	8b 58 10             	mov    0x10(%eax),%ebx
  801dff:	8b 50 14             	mov    0x14(%eax),%edx
  801e02:	89 95 8c fd ff ff    	mov    %edx,-0x274(%ebp)
  801e08:	8b 40 08             	mov    0x8(%eax),%eax
  801e0b:	89 85 90 fd ff ff    	mov    %eax,-0x270(%ebp)
	int i, r;
	void *blk;

	//cprintf("map_segment %x+%x\n", va, memsz);

	if ((i = PGOFF(va))) {
  801e11:	25 ff 0f 00 00       	and    $0xfff,%eax
  801e16:	74 16                	je     801e2e <spawn+0x336>
		va -= i;
  801e18:	29 85 90 fd ff ff    	sub    %eax,-0x270(%ebp)
		memsz += i;
  801e1e:	01 c2                	add    %eax,%edx
  801e20:	89 95 8c fd ff ff    	mov    %edx,-0x274(%ebp)
		filesz += i;
  801e26:	01 c3                	add    %eax,%ebx
		fileoffset -= i;
  801e28:	29 85 78 fd ff ff    	sub    %eax,-0x288(%ebp)
	}

	for (i = 0; i < memsz; i += PGSIZE) {
  801e2e:	83 bd 8c fd ff ff 00 	cmpl   $0x0,-0x274(%ebp)
  801e35:	0f 84 37 01 00 00    	je     801f72 <spawn+0x47a>
  801e3b:	bf 00 00 00 00       	mov    $0x0,%edi
  801e40:	be 00 00 00 00       	mov    $0x0,%esi
		if (i >= filesz) {
  801e45:	39 fb                	cmp    %edi,%ebx
  801e47:	77 31                	ja     801e7a <spawn+0x382>
			// allocate a blank page
			if ((r = sys_page_alloc(child, (void*) (va + i), perm)) < 0)
  801e49:	8b 95 94 fd ff ff    	mov    -0x26c(%ebp),%edx
  801e4f:	89 54 24 08          	mov    %edx,0x8(%esp)
  801e53:	03 bd 90 fd ff ff    	add    -0x270(%ebp),%edi
  801e59:	89 7c 24 04          	mov    %edi,0x4(%esp)
  801e5d:	8b 85 84 fd ff ff    	mov    -0x27c(%ebp),%eax
  801e63:	89 04 24             	mov    %eax,(%esp)
  801e66:	e8 4b f2 ff ff       	call   8010b6 <sys_page_alloc>
  801e6b:	85 c0                	test   %eax,%eax
  801e6d:	0f 89 eb 00 00 00    	jns    801f5e <spawn+0x466>
  801e73:	89 c3                	mov    %eax,%ebx
  801e75:	e9 69 02 00 00       	jmp    8020e3 <spawn+0x5eb>
				return r;
		} else {
			// from file
			if ((r = sys_page_alloc(0, UTEMP, PTE_P|PTE_U|PTE_W)) < 0)
  801e7a:	c7 44 24 08 07 00 00 	movl   $0x7,0x8(%esp)
  801e81:	00 
  801e82:	c7 44 24 04 00 00 40 	movl   $0x400000,0x4(%esp)
  801e89:	00 
  801e8a:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801e91:	e8 20 f2 ff ff       	call   8010b6 <sys_page_alloc>
  801e96:	85 c0                	test   %eax,%eax
  801e98:	0f 88 3b 02 00 00    	js     8020d9 <spawn+0x5e1>
				return r;
			if ((r = seek(fd, fileoffset + i)) < 0)
  801e9e:	8b 85 78 fd ff ff    	mov    -0x288(%ebp),%eax
  801ea4:	8d 04 06             	lea    (%esi,%eax,1),%eax
  801ea7:	89 44 24 04          	mov    %eax,0x4(%esp)
  801eab:	8b 95 88 fd ff ff    	mov    -0x278(%ebp),%edx
  801eb1:	89 14 24             	mov    %edx,(%esp)
  801eb4:	e8 0c f4 ff ff       	call   8012c5 <seek>
  801eb9:	85 c0                	test   %eax,%eax
  801ebb:	0f 88 1c 02 00 00    	js     8020dd <spawn+0x5e5>
				return r;
			if ((r = read(fd, UTEMP, MIN(PGSIZE, filesz-i))) < 0)
  801ec1:	89 d8                	mov    %ebx,%eax
  801ec3:	29 f8                	sub    %edi,%eax
  801ec5:	3d 00 10 00 00       	cmp    $0x1000,%eax
  801eca:	ba 00 10 00 00       	mov    $0x1000,%edx
  801ecf:	0f 47 c2             	cmova  %edx,%eax
  801ed2:	89 44 24 08          	mov    %eax,0x8(%esp)
  801ed6:	c7 44 24 04 00 00 40 	movl   $0x400000,0x4(%esp)
  801edd:	00 
  801ede:	8b 85 88 fd ff ff    	mov    -0x278(%ebp),%eax
  801ee4:	89 04 24             	mov    %eax,(%esp)
  801ee7:	e8 f7 f5 ff ff       	call   8014e3 <read>
  801eec:	85 c0                	test   %eax,%eax
  801eee:	0f 88 ed 01 00 00    	js     8020e1 <spawn+0x5e9>
				return r;
			if ((r = sys_page_map(0, UTEMP, child, (void*) (va + i), perm)) < 0)
  801ef4:	8b 95 94 fd ff ff    	mov    -0x26c(%ebp),%edx
  801efa:	89 54 24 10          	mov    %edx,0x10(%esp)
  801efe:	03 bd 90 fd ff ff    	add    -0x270(%ebp),%edi
  801f04:	89 7c 24 0c          	mov    %edi,0xc(%esp)
  801f08:	8b 85 84 fd ff ff    	mov    -0x27c(%ebp),%eax
  801f0e:	89 44 24 08          	mov    %eax,0x8(%esp)
  801f12:	c7 44 24 04 00 00 40 	movl   $0x400000,0x4(%esp)
  801f19:	00 
  801f1a:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801f21:	e8 32 f1 ff ff       	call   801058 <sys_page_map>
  801f26:	85 c0                	test   %eax,%eax
  801f28:	79 20                	jns    801f4a <spawn+0x452>
				panic("spawn: sys_page_map data: %e", r);
  801f2a:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801f2e:	c7 44 24 08 43 34 80 	movl   $0x803443,0x8(%esp)
  801f35:	00 
  801f36:	c7 44 24 04 0c 01 00 	movl   $0x10c,0x4(%esp)
  801f3d:	00 
  801f3e:	c7 04 24 37 34 80 00 	movl   $0x803437,(%esp)
  801f45:	e8 7e e2 ff ff       	call   8001c8 <_panic>
			sys_page_unmap(0, UTEMP);
  801f4a:	c7 44 24 04 00 00 40 	movl   $0x400000,0x4(%esp)
  801f51:	00 
  801f52:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801f59:	e8 9c f0 ff ff       	call   800ffa <sys_page_unmap>
		memsz += i;
		filesz += i;
		fileoffset -= i;
	}

	for (i = 0; i < memsz; i += PGSIZE) {
  801f5e:	81 c6 00 10 00 00    	add    $0x1000,%esi
  801f64:	89 f7                	mov    %esi,%edi
  801f66:	39 b5 8c fd ff ff    	cmp    %esi,-0x274(%ebp)
  801f6c:	0f 87 d3 fe ff ff    	ja     801e45 <spawn+0x34d>
	if ((r = init_stack(child, argv, &child_tf.tf_esp)) < 0)
		return r;

	// Set up program segments as defined in ELF header.
	ph = (struct Proghdr*) (elf_buf + elf->e_phoff);
	for (i = 0; i < elf->e_phnum; i++, ph++) {
  801f72:	83 85 7c fd ff ff 01 	addl   $0x1,-0x284(%ebp)
  801f79:	0f b7 85 14 fe ff ff 	movzwl -0x1ec(%ebp),%eax
  801f80:	3b 85 7c fd ff ff    	cmp    -0x284(%ebp),%eax
  801f86:	7e 0c                	jle    801f94 <spawn+0x49c>
  801f88:	83 85 80 fd ff ff 20 	addl   $0x20,-0x280(%ebp)
  801f8f:	e9 33 fe ff ff       	jmp    801dc7 <spawn+0x2cf>
			perm |= PTE_W;
		if ((r = map_segment(child, ph->p_va, ph->p_memsz, 
				     fd, ph->p_filesz, ph->p_offset, perm)) < 0)
			goto error;
	}
	close(fd);
  801f94:	8b 95 88 fd ff ff    	mov    -0x278(%ebp),%edx
  801f9a:	89 14 24             	mov    %edx,(%esp)
  801f9d:	e8 fa f6 ff ff       	call   80169c <close>
static int
copy_shared_pages(envid_t child)
{
    int va;
    int r=0;
    envid_t cur = sys_getenvid();
  801fa2:	e8 a2 f1 ff ff       	call   801149 <sys_getenvid>
  801fa7:	89 85 94 fd ff ff    	mov    %eax,-0x26c(%ebp)
  801fad:	b8 00 00 00 00       	mov    $0x0,%eax
  801fb2:	bb 00 00 00 00       	mov    $0x0,%ebx
    for (va=0;va<USTACKTOP; va+=PGSIZE) {
        if (((vpd[PDX(va)] & PTE_P) && (vpt[VPN(va)] & PTE_P) && (vpt[VPN(va)] & PTE_SHARE))) {
  801fb7:	be 00 d0 7b ef       	mov    $0xef7bd000,%esi
  801fbc:	bf 00 00 40 ef       	mov    $0xef400000,%edi
  801fc1:	89 c2                	mov    %eax,%edx
  801fc3:	89 d1                	mov    %edx,%ecx
  801fc5:	c1 e9 16             	shr    $0x16,%ecx
  801fc8:	8b 0c 8e             	mov    (%esi,%ecx,4),%ecx
  801fcb:	f6 c1 01             	test   $0x1,%cl
  801fce:	74 5f                	je     80202f <spawn+0x537>
  801fd0:	c1 ea 0c             	shr    $0xc,%edx
  801fd3:	8b 0c 97             	mov    (%edi,%edx,4),%ecx
  801fd6:	f6 c1 01             	test   $0x1,%cl
  801fd9:	74 54                	je     80202f <spawn+0x537>
  801fdb:	8b 0c 97             	mov    (%edi,%edx,4),%ecx
  801fde:	f6 c5 04             	test   $0x4,%ch
  801fe1:	74 4c                	je     80202f <spawn+0x537>
            if((r=sys_page_map(cur, (void *)(va), child, (void *)(va), vpt[VPN(va)]&PTE_USER))<0)
  801fe3:	8b 04 97             	mov    (%edi,%edx,4),%eax
  801fe6:	25 07 0e 00 00       	and    $0xe07,%eax
  801feb:	89 44 24 10          	mov    %eax,0x10(%esp)
  801fef:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  801ff3:	8b 85 84 fd ff ff    	mov    -0x27c(%ebp),%eax
  801ff9:	89 44 24 08          	mov    %eax,0x8(%esp)
  801ffd:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  802001:	8b 95 94 fd ff ff    	mov    -0x26c(%ebp),%edx
  802007:	89 14 24             	mov    %edx,(%esp)
  80200a:	e8 49 f0 ff ff       	call   801058 <sys_page_map>
  80200f:	85 c0                	test   %eax,%eax
  802011:	79 1c                	jns    80202f <spawn+0x537>
                panic("copy_shared_pages: error sharing\n");
  802013:	c7 44 24 08 d0 34 80 	movl   $0x8034d0,0x8(%esp)
  80201a:	00 
  80201b:	c7 44 24 04 1d 01 00 	movl   $0x11d,0x4(%esp)
  802022:	00 
  802023:	c7 04 24 37 34 80 00 	movl   $0x803437,(%esp)
  80202a:	e8 99 e1 ff ff       	call   8001c8 <_panic>
copy_shared_pages(envid_t child)
{
    int va;
    int r=0;
    envid_t cur = sys_getenvid();
    for (va=0;va<USTACKTOP; va+=PGSIZE) {
  80202f:	81 c3 00 10 00 00    	add    $0x1000,%ebx
  802035:	89 da                	mov    %ebx,%edx
  802037:	81 fb 00 e0 bf ee    	cmp    $0xeebfe000,%ebx
  80203d:	75 84                	jne    801fc3 <spawn+0x4cb>
	}
	close(fd);
	fd = -1;

	// Copy shared library state.
	if ((r = copy_shared_pages(child)) < 0)
  80203f:	85 c0                	test   %eax,%eax
  802041:	79 20                	jns    802063 <spawn+0x56b>
		panic("copy_shared_pages: %e", r);
  802043:	89 44 24 0c          	mov    %eax,0xc(%esp)
  802047:	c7 44 24 08 60 34 80 	movl   $0x803460,0x8(%esp)
  80204e:	00 
  80204f:	c7 44 24 04 82 00 00 	movl   $0x82,0x4(%esp)
  802056:	00 
  802057:	c7 04 24 37 34 80 00 	movl   $0x803437,(%esp)
  80205e:	e8 65 e1 ff ff       	call   8001c8 <_panic>

	if ((r = sys_env_set_trapframe(child, &child_tf)) < 0)
  802063:	8d 85 a4 fd ff ff    	lea    -0x25c(%ebp),%eax
  802069:	89 44 24 04          	mov    %eax,0x4(%esp)
  80206d:	8b 85 84 fd ff ff    	mov    -0x27c(%ebp),%eax
  802073:	89 04 24             	mov    %eax,(%esp)
  802076:	e8 c3 ee ff ff       	call   800f3e <sys_env_set_trapframe>
  80207b:	85 c0                	test   %eax,%eax
  80207d:	79 20                	jns    80209f <spawn+0x5a7>
		panic("sys_env_set_trapframe: %e", r);
  80207f:	89 44 24 0c          	mov    %eax,0xc(%esp)
  802083:	c7 44 24 08 76 34 80 	movl   $0x803476,0x8(%esp)
  80208a:	00 
  80208b:	c7 44 24 04 85 00 00 	movl   $0x85,0x4(%esp)
  802092:	00 
  802093:	c7 04 24 37 34 80 00 	movl   $0x803437,(%esp)
  80209a:	e8 29 e1 ff ff       	call   8001c8 <_panic>

	if ((r = sys_env_set_status(child, ENV_RUNNABLE)) < 0)
  80209f:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  8020a6:	00 
  8020a7:	8b 95 84 fd ff ff    	mov    -0x27c(%ebp),%edx
  8020ad:	89 14 24             	mov    %edx,(%esp)
  8020b0:	e8 e7 ee ff ff       	call   800f9c <sys_env_set_status>
  8020b5:	85 c0                	test   %eax,%eax
  8020b7:	79 48                	jns    802101 <spawn+0x609>
		panic("sys_env_set_status: %e", r);
  8020b9:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8020bd:	c7 44 24 08 90 34 80 	movl   $0x803490,0x8(%esp)
  8020c4:	00 
  8020c5:	c7 44 24 04 88 00 00 	movl   $0x88,0x4(%esp)
  8020cc:	00 
  8020cd:	c7 04 24 37 34 80 00 	movl   $0x803437,(%esp)
  8020d4:	e8 ef e0 ff ff       	call   8001c8 <_panic>
  8020d9:	89 c3                	mov    %eax,%ebx
  8020db:	eb 06                	jmp    8020e3 <spawn+0x5eb>
  8020dd:	89 c3                	mov    %eax,%ebx
  8020df:	eb 02                	jmp    8020e3 <spawn+0x5eb>
  8020e1:	89 c3                	mov    %eax,%ebx

	return child;

error:
	sys_env_destroy(child);
  8020e3:	8b 85 84 fd ff ff    	mov    -0x27c(%ebp),%eax
  8020e9:	89 04 24             	mov    %eax,(%esp)
  8020ec:	e8 8c f0 ff ff       	call   80117d <sys_env_destroy>
	close(fd);
  8020f1:	8b 95 88 fd ff ff    	mov    -0x278(%ebp),%edx
  8020f7:	89 14 24             	mov    %edx,(%esp)
  8020fa:	e8 9d f5 ff ff       	call   80169c <close>
	return r;
  8020ff:	eb 06                	jmp    802107 <spawn+0x60f>
  802101:	8b 9d 84 fd ff ff    	mov    -0x27c(%ebp),%ebx
}
  802107:	89 d8                	mov    %ebx,%eax
  802109:	81 c4 9c 02 00 00    	add    $0x29c,%esp
  80210f:	5b                   	pop    %ebx
  802110:	5e                   	pop    %esi
  802111:	5f                   	pop    %edi
  802112:	5d                   	pop    %ebp
  802113:	c3                   	ret    

00802114 <spawnl>:

// Spawn, taking command-line arguments array directly on the stack.
int
spawnl(const char *prog, const char *arg0, ...)
{
  802114:	55                   	push   %ebp
  802115:	89 e5                	mov    %esp,%ebp
  802117:	83 ec 18             	sub    $0x18,%esp
	return spawn(prog, &arg0);
  80211a:	8d 45 0c             	lea    0xc(%ebp),%eax
  80211d:	89 44 24 04          	mov    %eax,0x4(%esp)
  802121:	8b 45 08             	mov    0x8(%ebp),%eax
  802124:	89 04 24             	mov    %eax,(%esp)
  802127:	e8 cc f9 ff ff       	call   801af8 <spawn>
}
  80212c:	c9                   	leave  
  80212d:	c3                   	ret    
	...

00802130 <devsock_stat>:
	return nsipc_send(fd->fd_sock.sockid, buf, n, 0);
}

static int
devsock_stat(struct Fd *fd, struct Stat *stat)
{
  802130:	55                   	push   %ebp
  802131:	89 e5                	mov    %esp,%ebp
  802133:	83 ec 18             	sub    $0x18,%esp
	strcpy(stat->st_name, "<sock>");
  802136:	c7 44 24 04 f2 34 80 	movl   $0x8034f2,0x4(%esp)
  80213d:	00 
  80213e:	8b 45 0c             	mov    0xc(%ebp),%eax
  802141:	89 04 24             	mov    %eax,(%esp)
  802144:	e8 11 e8 ff ff       	call   80095a <strcpy>
	return 0;
}
  802149:	b8 00 00 00 00       	mov    $0x0,%eax
  80214e:	c9                   	leave  
  80214f:	c3                   	ret    

00802150 <devsock_close>:
	return nsipc_shutdown(r, how);
}

static int
devsock_close(struct Fd *fd)
{
  802150:	55                   	push   %ebp
  802151:	89 e5                	mov    %esp,%ebp
  802153:	83 ec 18             	sub    $0x18,%esp
	return nsipc_close(fd->fd_sock.sockid);
  802156:	8b 45 08             	mov    0x8(%ebp),%eax
  802159:	8b 40 0c             	mov    0xc(%eax),%eax
  80215c:	89 04 24             	mov    %eax,(%esp)
  80215f:	e8 9d 02 00 00       	call   802401 <nsipc_close>
}
  802164:	c9                   	leave  
  802165:	c3                   	ret    

00802166 <devsock_write>:
	return nsipc_recv(fd->fd_sock.sockid, buf, n, 0);
}

static ssize_t
devsock_write(struct Fd *fd, const void *buf, size_t n)
{
  802166:	55                   	push   %ebp
  802167:	89 e5                	mov    %esp,%ebp
  802169:	83 ec 18             	sub    $0x18,%esp
	return nsipc_send(fd->fd_sock.sockid, buf, n, 0);
  80216c:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  802173:	00 
  802174:	8b 45 10             	mov    0x10(%ebp),%eax
  802177:	89 44 24 08          	mov    %eax,0x8(%esp)
  80217b:	8b 45 0c             	mov    0xc(%ebp),%eax
  80217e:	89 44 24 04          	mov    %eax,0x4(%esp)
  802182:	8b 45 08             	mov    0x8(%ebp),%eax
  802185:	8b 40 0c             	mov    0xc(%eax),%eax
  802188:	89 04 24             	mov    %eax,(%esp)
  80218b:	e8 ad 02 00 00       	call   80243d <nsipc_send>
}
  802190:	c9                   	leave  
  802191:	c3                   	ret    

00802192 <devsock_read>:
	return nsipc_listen(r, backlog);
}

static ssize_t
devsock_read(struct Fd *fd, void *buf, size_t n)
{
  802192:	55                   	push   %ebp
  802193:	89 e5                	mov    %esp,%ebp
  802195:	83 ec 18             	sub    $0x18,%esp
	return nsipc_recv(fd->fd_sock.sockid, buf, n, 0);
  802198:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  80219f:	00 
  8021a0:	8b 45 10             	mov    0x10(%ebp),%eax
  8021a3:	89 44 24 08          	mov    %eax,0x8(%esp)
  8021a7:	8b 45 0c             	mov    0xc(%ebp),%eax
  8021aa:	89 44 24 04          	mov    %eax,0x4(%esp)
  8021ae:	8b 45 08             	mov    0x8(%ebp),%eax
  8021b1:	8b 40 0c             	mov    0xc(%eax),%eax
  8021b4:	89 04 24             	mov    %eax,(%esp)
  8021b7:	e8 f4 02 00 00       	call   8024b0 <nsipc_recv>
}
  8021bc:	c9                   	leave  
  8021bd:	c3                   	ret    

008021be <alloc_sockfd>:
	return sfd->fd_sock.sockid;
}

static int
alloc_sockfd(int sockid)
{
  8021be:	55                   	push   %ebp
  8021bf:	89 e5                	mov    %esp,%ebp
  8021c1:	56                   	push   %esi
  8021c2:	53                   	push   %ebx
  8021c3:	83 ec 20             	sub    $0x20,%esp
  8021c6:	89 c6                	mov    %eax,%esi
	struct Fd *sfd;
	int r;

	if ((r = fd_alloc(&sfd)) < 0
  8021c8:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8021cb:	89 04 24             	mov    %eax,(%esp)
  8021ce:	e8 38 f0 ff ff       	call   80120b <fd_alloc>
  8021d3:	89 c3                	mov    %eax,%ebx
  8021d5:	85 c0                	test   %eax,%eax
  8021d7:	78 21                	js     8021fa <alloc_sockfd+0x3c>
	    || (r = sys_page_alloc(0, sfd, PTE_P|PTE_W|PTE_U)) < 0) {
  8021d9:	c7 44 24 08 07 00 00 	movl   $0x7,0x8(%esp)
  8021e0:	00 
  8021e1:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8021e4:	89 44 24 04          	mov    %eax,0x4(%esp)
  8021e8:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8021ef:	e8 c2 ee ff ff       	call   8010b6 <sys_page_alloc>
  8021f4:	89 c3                	mov    %eax,%ebx
alloc_sockfd(int sockid)
{
	struct Fd *sfd;
	int r;

	if ((r = fd_alloc(&sfd)) < 0
  8021f6:	85 c0                	test   %eax,%eax
  8021f8:	79 0a                	jns    802204 <alloc_sockfd+0x46>
	    || (r = sys_page_alloc(0, sfd, PTE_P|PTE_W|PTE_U)) < 0) {
		nsipc_close(sockid);
  8021fa:	89 34 24             	mov    %esi,(%esp)
  8021fd:	e8 ff 01 00 00       	call   802401 <nsipc_close>
		return r;
  802202:	eb 28                	jmp    80222c <alloc_sockfd+0x6e>
	}

	sfd->fd_dev_id = devsock.dev_id;
  802204:	8b 15 20 70 80 00    	mov    0x807020,%edx
  80220a:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80220d:	89 10                	mov    %edx,(%eax)
	sfd->fd_omode = O_RDWR;
  80220f:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802212:	c7 40 08 02 00 00 00 	movl   $0x2,0x8(%eax)
	sfd->fd_sock.sockid = sockid;
  802219:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80221c:	89 70 0c             	mov    %esi,0xc(%eax)
	return fd2num(sfd);
  80221f:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802222:	89 04 24             	mov    %eax,(%esp)
  802225:	e8 b6 ef ff ff       	call   8011e0 <fd2num>
  80222a:	89 c3                	mov    %eax,%ebx
}
  80222c:	89 d8                	mov    %ebx,%eax
  80222e:	83 c4 20             	add    $0x20,%esp
  802231:	5b                   	pop    %ebx
  802232:	5e                   	pop    %esi
  802233:	5d                   	pop    %ebp
  802234:	c3                   	ret    

00802235 <socket>:
	return 0;
}

int
socket(int domain, int type, int protocol)
{
  802235:	55                   	push   %ebp
  802236:	89 e5                	mov    %esp,%ebp
  802238:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = nsipc_socket(domain, type, protocol)) < 0)
  80223b:	8b 45 10             	mov    0x10(%ebp),%eax
  80223e:	89 44 24 08          	mov    %eax,0x8(%esp)
  802242:	8b 45 0c             	mov    0xc(%ebp),%eax
  802245:	89 44 24 04          	mov    %eax,0x4(%esp)
  802249:	8b 45 08             	mov    0x8(%ebp),%eax
  80224c:	89 04 24             	mov    %eax,(%esp)
  80224f:	e8 61 01 00 00       	call   8023b5 <nsipc_socket>
  802254:	85 c0                	test   %eax,%eax
  802256:	78 05                	js     80225d <socket+0x28>
		return r;
	return alloc_sockfd(r);
  802258:	e8 61 ff ff ff       	call   8021be <alloc_sockfd>
}
  80225d:	c9                   	leave  
  80225e:	66 90                	xchg   %ax,%ax
  802260:	c3                   	ret    

00802261 <fd2sockid>:
	.dev_stat =	devsock_stat,
};

static int
fd2sockid(int fd)
{
  802261:	55                   	push   %ebp
  802262:	89 e5                	mov    %esp,%ebp
  802264:	83 ec 28             	sub    $0x28,%esp
	struct Fd *sfd;
	int r;

	if ((r = fd_lookup(fd, &sfd)) < 0)
  802267:	8d 55 f4             	lea    -0xc(%ebp),%edx
  80226a:	89 54 24 04          	mov    %edx,0x4(%esp)
  80226e:	89 04 24             	mov    %eax,(%esp)
  802271:	e8 07 f0 ff ff       	call   80127d <fd_lookup>
  802276:	85 c0                	test   %eax,%eax
  802278:	78 15                	js     80228f <fd2sockid+0x2e>
		return r;
	if (sfd->fd_dev_id != devsock.dev_id)
  80227a:	8b 55 f4             	mov    -0xc(%ebp),%edx
  80227d:	8b 0a                	mov    (%edx),%ecx
  80227f:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  802284:	3b 0d 20 70 80 00    	cmp    0x807020,%ecx
  80228a:	75 03                	jne    80228f <fd2sockid+0x2e>
		return -E_NOT_SUPP;
	return sfd->fd_sock.sockid;
  80228c:	8b 42 0c             	mov    0xc(%edx),%eax
}
  80228f:	c9                   	leave  
  802290:	c3                   	ret    

00802291 <listen>:
	return nsipc_connect(r, name, namelen);
}

int
listen(int s, int backlog)
{
  802291:	55                   	push   %ebp
  802292:	89 e5                	mov    %esp,%ebp
  802294:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  802297:	8b 45 08             	mov    0x8(%ebp),%eax
  80229a:	e8 c2 ff ff ff       	call   802261 <fd2sockid>
  80229f:	85 c0                	test   %eax,%eax
  8022a1:	78 0f                	js     8022b2 <listen+0x21>
		return r;
	return nsipc_listen(r, backlog);
  8022a3:	8b 55 0c             	mov    0xc(%ebp),%edx
  8022a6:	89 54 24 04          	mov    %edx,0x4(%esp)
  8022aa:	89 04 24             	mov    %eax,(%esp)
  8022ad:	e8 2d 01 00 00       	call   8023df <nsipc_listen>
}
  8022b2:	c9                   	leave  
  8022b3:	c3                   	ret    

008022b4 <connect>:
	return nsipc_close(fd->fd_sock.sockid);
}

int
connect(int s, const struct sockaddr *name, socklen_t namelen)
{
  8022b4:	55                   	push   %ebp
  8022b5:	89 e5                	mov    %esp,%ebp
  8022b7:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  8022ba:	8b 45 08             	mov    0x8(%ebp),%eax
  8022bd:	e8 9f ff ff ff       	call   802261 <fd2sockid>
  8022c2:	85 c0                	test   %eax,%eax
  8022c4:	78 16                	js     8022dc <connect+0x28>
		return r;
	return nsipc_connect(r, name, namelen);
  8022c6:	8b 55 10             	mov    0x10(%ebp),%edx
  8022c9:	89 54 24 08          	mov    %edx,0x8(%esp)
  8022cd:	8b 55 0c             	mov    0xc(%ebp),%edx
  8022d0:	89 54 24 04          	mov    %edx,0x4(%esp)
  8022d4:	89 04 24             	mov    %eax,(%esp)
  8022d7:	e8 54 02 00 00       	call   802530 <nsipc_connect>
}
  8022dc:	c9                   	leave  
  8022dd:	c3                   	ret    

008022de <shutdown>:
	return nsipc_bind(r, name, namelen);
}

int
shutdown(int s, int how)
{
  8022de:	55                   	push   %ebp
  8022df:	89 e5                	mov    %esp,%ebp
  8022e1:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  8022e4:	8b 45 08             	mov    0x8(%ebp),%eax
  8022e7:	e8 75 ff ff ff       	call   802261 <fd2sockid>
  8022ec:	85 c0                	test   %eax,%eax
  8022ee:	78 0f                	js     8022ff <shutdown+0x21>
		return r;
	return nsipc_shutdown(r, how);
  8022f0:	8b 55 0c             	mov    0xc(%ebp),%edx
  8022f3:	89 54 24 04          	mov    %edx,0x4(%esp)
  8022f7:	89 04 24             	mov    %eax,(%esp)
  8022fa:	e8 1c 01 00 00       	call   80241b <nsipc_shutdown>
}
  8022ff:	c9                   	leave  
  802300:	c3                   	ret    

00802301 <bind>:
	return alloc_sockfd(r);
}

int
bind(int s, struct sockaddr *name, socklen_t namelen)
{
  802301:	55                   	push   %ebp
  802302:	89 e5                	mov    %esp,%ebp
  802304:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  802307:	8b 45 08             	mov    0x8(%ebp),%eax
  80230a:	e8 52 ff ff ff       	call   802261 <fd2sockid>
  80230f:	85 c0                	test   %eax,%eax
  802311:	78 16                	js     802329 <bind+0x28>
		return r;
	return nsipc_bind(r, name, namelen);
  802313:	8b 55 10             	mov    0x10(%ebp),%edx
  802316:	89 54 24 08          	mov    %edx,0x8(%esp)
  80231a:	8b 55 0c             	mov    0xc(%ebp),%edx
  80231d:	89 54 24 04          	mov    %edx,0x4(%esp)
  802321:	89 04 24             	mov    %eax,(%esp)
  802324:	e8 46 02 00 00       	call   80256f <nsipc_bind>
}
  802329:	c9                   	leave  
  80232a:	c3                   	ret    

0080232b <accept>:
	return fd2num(sfd);
}

int
accept(int s, struct sockaddr *addr, socklen_t *addrlen)
{
  80232b:	55                   	push   %ebp
  80232c:	89 e5                	mov    %esp,%ebp
  80232e:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  802331:	8b 45 08             	mov    0x8(%ebp),%eax
  802334:	e8 28 ff ff ff       	call   802261 <fd2sockid>
  802339:	85 c0                	test   %eax,%eax
  80233b:	78 1f                	js     80235c <accept+0x31>
		return r;
	if ((r = nsipc_accept(r, addr, addrlen)) < 0)
  80233d:	8b 55 10             	mov    0x10(%ebp),%edx
  802340:	89 54 24 08          	mov    %edx,0x8(%esp)
  802344:	8b 55 0c             	mov    0xc(%ebp),%edx
  802347:	89 54 24 04          	mov    %edx,0x4(%esp)
  80234b:	89 04 24             	mov    %eax,(%esp)
  80234e:	e8 5b 02 00 00       	call   8025ae <nsipc_accept>
  802353:	85 c0                	test   %eax,%eax
  802355:	78 05                	js     80235c <accept+0x31>
		return r;
	return alloc_sockfd(r);
  802357:	e8 62 fe ff ff       	call   8021be <alloc_sockfd>
}
  80235c:	c9                   	leave  
  80235d:	8d 76 00             	lea    0x0(%esi),%esi
  802360:	c3                   	ret    
	...

00802370 <nsipc>:
// may be written back to nsipcbuf.
// type: request code, passed as the simple integer IPC value.
// Returns 0 if successful, < 0 on failure.
static int
nsipc(unsigned type)
{
  802370:	55                   	push   %ebp
  802371:	89 e5                	mov    %esp,%ebp
  802373:	83 ec 28             	sub    $0x28,%esp
    int r=0;
    envid_t from;
	if (debug)
		cprintf("[%08x] nsipc %d\n", env->env_id, type);

	ipc_send(envs[2].env_id, type, &nsipcbuf, PTE_P|PTE_W|PTE_U);
  802376:	8b 15 44 01 c0 ee    	mov    0xeec00144,%edx
  80237c:	c7 44 24 0c 07 00 00 	movl   $0x7,0xc(%esp)
  802383:	00 
  802384:	c7 44 24 08 00 60 80 	movl   $0x806000,0x8(%esp)
  80238b:	00 
  80238c:	89 44 24 04          	mov    %eax,0x4(%esp)
  802390:	89 14 24             	mov    %edx,(%esp)
  802393:	e8 18 08 00 00       	call   802bb0 <ipc_send>
	r=ipc_recv(&from, NULL, NULL);
  802398:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  80239f:	00 
  8023a0:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  8023a7:	00 
  8023a8:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8023ab:	89 04 24             	mov    %eax,(%esp)
  8023ae:	e8 6f 08 00 00       	call   802c22 <ipc_recv>
    return r;
}
  8023b3:	c9                   	leave  
  8023b4:	c3                   	ret    

008023b5 <nsipc_socket>:
	return nsipc(NSREQ_SEND);
}

int
nsipc_socket(int domain, int type, int protocol)
{
  8023b5:	55                   	push   %ebp
  8023b6:	89 e5                	mov    %esp,%ebp
  8023b8:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.socket.req_domain = domain;
  8023bb:	8b 45 08             	mov    0x8(%ebp),%eax
  8023be:	a3 00 60 80 00       	mov    %eax,0x806000
	nsipcbuf.socket.req_type = type;
  8023c3:	8b 45 0c             	mov    0xc(%ebp),%eax
  8023c6:	a3 04 60 80 00       	mov    %eax,0x806004
	nsipcbuf.socket.req_protocol = protocol;
  8023cb:	8b 45 10             	mov    0x10(%ebp),%eax
  8023ce:	a3 08 60 80 00       	mov    %eax,0x806008
	return nsipc(NSREQ_SOCKET);
  8023d3:	b8 09 00 00 00       	mov    $0x9,%eax
  8023d8:	e8 93 ff ff ff       	call   802370 <nsipc>
}
  8023dd:	c9                   	leave  
  8023de:	c3                   	ret    

008023df <nsipc_listen>:
	return nsipc(NSREQ_CONNECT);
}

int
nsipc_listen(int s, int backlog)
{
  8023df:	55                   	push   %ebp
  8023e0:	89 e5                	mov    %esp,%ebp
  8023e2:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.listen.req_s = s;
  8023e5:	8b 45 08             	mov    0x8(%ebp),%eax
  8023e8:	a3 00 60 80 00       	mov    %eax,0x806000
	nsipcbuf.listen.req_backlog = backlog;
  8023ed:	8b 45 0c             	mov    0xc(%ebp),%eax
  8023f0:	a3 04 60 80 00       	mov    %eax,0x806004
	return nsipc(NSREQ_LISTEN);
  8023f5:	b8 06 00 00 00       	mov    $0x6,%eax
  8023fa:	e8 71 ff ff ff       	call   802370 <nsipc>
}
  8023ff:	c9                   	leave  
  802400:	c3                   	ret    

00802401 <nsipc_close>:
	return nsipc(NSREQ_SHUTDOWN);
}

int
nsipc_close(int s)
{
  802401:	55                   	push   %ebp
  802402:	89 e5                	mov    %esp,%ebp
  802404:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.close.req_s = s;
  802407:	8b 45 08             	mov    0x8(%ebp),%eax
  80240a:	a3 00 60 80 00       	mov    %eax,0x806000
	return nsipc(NSREQ_CLOSE);
  80240f:	b8 04 00 00 00       	mov    $0x4,%eax
  802414:	e8 57 ff ff ff       	call   802370 <nsipc>
}
  802419:	c9                   	leave  
  80241a:	c3                   	ret    

0080241b <nsipc_shutdown>:
	return nsipc(NSREQ_BIND);
}

int
nsipc_shutdown(int s, int how)
{
  80241b:	55                   	push   %ebp
  80241c:	89 e5                	mov    %esp,%ebp
  80241e:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.shutdown.req_s = s;
  802421:	8b 45 08             	mov    0x8(%ebp),%eax
  802424:	a3 00 60 80 00       	mov    %eax,0x806000
	nsipcbuf.shutdown.req_how = how;
  802429:	8b 45 0c             	mov    0xc(%ebp),%eax
  80242c:	a3 04 60 80 00       	mov    %eax,0x806004
	return nsipc(NSREQ_SHUTDOWN);
  802431:	b8 03 00 00 00       	mov    $0x3,%eax
  802436:	e8 35 ff ff ff       	call   802370 <nsipc>
}
  80243b:	c9                   	leave  
  80243c:	c3                   	ret    

0080243d <nsipc_send>:
	return r;
}

int
nsipc_send(int s, const void *buf, int size, unsigned int flags)
{
  80243d:	55                   	push   %ebp
  80243e:	89 e5                	mov    %esp,%ebp
  802440:	53                   	push   %ebx
  802441:	83 ec 14             	sub    $0x14,%esp
  802444:	8b 5d 10             	mov    0x10(%ebp),%ebx
	nsipcbuf.send.req_s = s;
  802447:	8b 45 08             	mov    0x8(%ebp),%eax
  80244a:	a3 00 60 80 00       	mov    %eax,0x806000
	assert(size < 1600);
  80244f:	81 fb 3f 06 00 00    	cmp    $0x63f,%ebx
  802455:	7e 24                	jle    80247b <nsipc_send+0x3e>
  802457:	c7 44 24 0c fe 34 80 	movl   $0x8034fe,0xc(%esp)
  80245e:	00 
  80245f:	c7 44 24 08 22 34 80 	movl   $0x803422,0x8(%esp)
  802466:	00 
  802467:	c7 44 24 04 69 00 00 	movl   $0x69,0x4(%esp)
  80246e:	00 
  80246f:	c7 04 24 0a 35 80 00 	movl   $0x80350a,(%esp)
  802476:	e8 4d dd ff ff       	call   8001c8 <_panic>
	memmove(&nsipcbuf.send.req_buf, buf, size);
  80247b:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  80247f:	8b 45 0c             	mov    0xc(%ebp),%eax
  802482:	89 44 24 04          	mov    %eax,0x4(%esp)
  802486:	c7 04 24 0c 60 80 00 	movl   $0x80600c,(%esp)
  80248d:	e8 83 e6 ff ff       	call   800b15 <memmove>
	nsipcbuf.send.req_size = size;
  802492:	89 1d 04 60 80 00    	mov    %ebx,0x806004
	nsipcbuf.send.req_flags = flags;
  802498:	8b 45 14             	mov    0x14(%ebp),%eax
  80249b:	a3 08 60 80 00       	mov    %eax,0x806008
	return nsipc(NSREQ_SEND);
  8024a0:	b8 08 00 00 00       	mov    $0x8,%eax
  8024a5:	e8 c6 fe ff ff       	call   802370 <nsipc>
}
  8024aa:	83 c4 14             	add    $0x14,%esp
  8024ad:	5b                   	pop    %ebx
  8024ae:	5d                   	pop    %ebp
  8024af:	c3                   	ret    

008024b0 <nsipc_recv>:
	return nsipc(NSREQ_LISTEN);
}

int
nsipc_recv(int s, void *mem, int len, unsigned int flags)
{
  8024b0:	55                   	push   %ebp
  8024b1:	89 e5                	mov    %esp,%ebp
  8024b3:	56                   	push   %esi
  8024b4:	53                   	push   %ebx
  8024b5:	83 ec 10             	sub    $0x10,%esp
  8024b8:	8b 75 10             	mov    0x10(%ebp),%esi
	int r;

	nsipcbuf.recv.req_s = s;
  8024bb:	8b 45 08             	mov    0x8(%ebp),%eax
  8024be:	a3 00 60 80 00       	mov    %eax,0x806000
	nsipcbuf.recv.req_len = len;
  8024c3:	89 35 04 60 80 00    	mov    %esi,0x806004
	nsipcbuf.recv.req_flags = flags;
  8024c9:	8b 45 14             	mov    0x14(%ebp),%eax
  8024cc:	a3 08 60 80 00       	mov    %eax,0x806008

	if ((r = nsipc(NSREQ_RECV)) >= 0) {
  8024d1:	b8 07 00 00 00       	mov    $0x7,%eax
  8024d6:	e8 95 fe ff ff       	call   802370 <nsipc>
  8024db:	89 c3                	mov    %eax,%ebx
  8024dd:	85 c0                	test   %eax,%eax
  8024df:	78 46                	js     802527 <nsipc_recv+0x77>
		assert(r < 1600 && r <= len);
  8024e1:	3d 3f 06 00 00       	cmp    $0x63f,%eax
  8024e6:	7f 04                	jg     8024ec <nsipc_recv+0x3c>
  8024e8:	39 c6                	cmp    %eax,%esi
  8024ea:	7d 24                	jge    802510 <nsipc_recv+0x60>
  8024ec:	c7 44 24 0c 16 35 80 	movl   $0x803516,0xc(%esp)
  8024f3:	00 
  8024f4:	c7 44 24 08 22 34 80 	movl   $0x803422,0x8(%esp)
  8024fb:	00 
  8024fc:	c7 44 24 04 5e 00 00 	movl   $0x5e,0x4(%esp)
  802503:	00 
  802504:	c7 04 24 0a 35 80 00 	movl   $0x80350a,(%esp)
  80250b:	e8 b8 dc ff ff       	call   8001c8 <_panic>
		memmove(mem, nsipcbuf.recvRet.ret_buf, r);
  802510:	89 44 24 08          	mov    %eax,0x8(%esp)
  802514:	c7 44 24 04 00 60 80 	movl   $0x806000,0x4(%esp)
  80251b:	00 
  80251c:	8b 45 0c             	mov    0xc(%ebp),%eax
  80251f:	89 04 24             	mov    %eax,(%esp)
  802522:	e8 ee e5 ff ff       	call   800b15 <memmove>
	}

	return r;
}
  802527:	89 d8                	mov    %ebx,%eax
  802529:	83 c4 10             	add    $0x10,%esp
  80252c:	5b                   	pop    %ebx
  80252d:	5e                   	pop    %esi
  80252e:	5d                   	pop    %ebp
  80252f:	c3                   	ret    

00802530 <nsipc_connect>:
	return nsipc(NSREQ_CLOSE);
}

int
nsipc_connect(int s, const struct sockaddr *name, socklen_t namelen)
{
  802530:	55                   	push   %ebp
  802531:	89 e5                	mov    %esp,%ebp
  802533:	53                   	push   %ebx
  802534:	83 ec 14             	sub    $0x14,%esp
  802537:	8b 5d 10             	mov    0x10(%ebp),%ebx
	nsipcbuf.connect.req_s = s;
  80253a:	8b 45 08             	mov    0x8(%ebp),%eax
  80253d:	a3 00 60 80 00       	mov    %eax,0x806000
	memmove(&nsipcbuf.connect.req_name, name, namelen);
  802542:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  802546:	8b 45 0c             	mov    0xc(%ebp),%eax
  802549:	89 44 24 04          	mov    %eax,0x4(%esp)
  80254d:	c7 04 24 04 60 80 00 	movl   $0x806004,(%esp)
  802554:	e8 bc e5 ff ff       	call   800b15 <memmove>
	nsipcbuf.connect.req_namelen = namelen;
  802559:	89 1d 14 60 80 00    	mov    %ebx,0x806014
	return nsipc(NSREQ_CONNECT);
  80255f:	b8 05 00 00 00       	mov    $0x5,%eax
  802564:	e8 07 fe ff ff       	call   802370 <nsipc>
}
  802569:	83 c4 14             	add    $0x14,%esp
  80256c:	5b                   	pop    %ebx
  80256d:	5d                   	pop    %ebp
  80256e:	c3                   	ret    

0080256f <nsipc_bind>:
	return r;
}

int
nsipc_bind(int s, struct sockaddr *name, socklen_t namelen)
{
  80256f:	55                   	push   %ebp
  802570:	89 e5                	mov    %esp,%ebp
  802572:	53                   	push   %ebx
  802573:	83 ec 14             	sub    $0x14,%esp
  802576:	8b 5d 10             	mov    0x10(%ebp),%ebx
	nsipcbuf.bind.req_s = s;
  802579:	8b 45 08             	mov    0x8(%ebp),%eax
  80257c:	a3 00 60 80 00       	mov    %eax,0x806000
	memmove(&nsipcbuf.bind.req_name, name, namelen);
  802581:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  802585:	8b 45 0c             	mov    0xc(%ebp),%eax
  802588:	89 44 24 04          	mov    %eax,0x4(%esp)
  80258c:	c7 04 24 04 60 80 00 	movl   $0x806004,(%esp)
  802593:	e8 7d e5 ff ff       	call   800b15 <memmove>
	nsipcbuf.bind.req_namelen = namelen;
  802598:	89 1d 14 60 80 00    	mov    %ebx,0x806014
	return nsipc(NSREQ_BIND);
  80259e:	b8 02 00 00 00       	mov    $0x2,%eax
  8025a3:	e8 c8 fd ff ff       	call   802370 <nsipc>
}
  8025a8:	83 c4 14             	add    $0x14,%esp
  8025ab:	5b                   	pop    %ebx
  8025ac:	5d                   	pop    %ebp
  8025ad:	c3                   	ret    

008025ae <nsipc_accept>:
    return r;
}

int
nsipc_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
{
  8025ae:	55                   	push   %ebp
  8025af:	89 e5                	mov    %esp,%ebp
  8025b1:	83 ec 18             	sub    $0x18,%esp
  8025b4:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  8025b7:	89 75 fc             	mov    %esi,-0x4(%ebp)
	int r;
	
	nsipcbuf.accept.req_s = s;
  8025ba:	8b 45 08             	mov    0x8(%ebp),%eax
  8025bd:	a3 00 60 80 00       	mov    %eax,0x806000
	if ((r = nsipc(NSREQ_ACCEPT)) >= 0) {
  8025c2:	b8 01 00 00 00       	mov    $0x1,%eax
  8025c7:	e8 a4 fd ff ff       	call   802370 <nsipc>
  8025cc:	89 c3                	mov    %eax,%ebx
  8025ce:	85 c0                	test   %eax,%eax
  8025d0:	78 25                	js     8025f7 <nsipc_accept+0x49>
		struct Nsret_accept *ret = &nsipcbuf.acceptRet;
		memmove(addr, &ret->ret_addr, ret->ret_addrlen);
  8025d2:	be 10 60 80 00       	mov    $0x806010,%esi
  8025d7:	8b 06                	mov    (%esi),%eax
  8025d9:	89 44 24 08          	mov    %eax,0x8(%esp)
  8025dd:	c7 44 24 04 00 60 80 	movl   $0x806000,0x4(%esp)
  8025e4:	00 
  8025e5:	8b 45 0c             	mov    0xc(%ebp),%eax
  8025e8:	89 04 24             	mov    %eax,(%esp)
  8025eb:	e8 25 e5 ff ff       	call   800b15 <memmove>
		*addrlen = ret->ret_addrlen;
  8025f0:	8b 16                	mov    (%esi),%edx
  8025f2:	8b 45 10             	mov    0x10(%ebp),%eax
  8025f5:	89 10                	mov    %edx,(%eax)
	}
	return r;
}
  8025f7:	89 d8                	mov    %ebx,%eax
  8025f9:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  8025fc:	8b 75 fc             	mov    -0x4(%ebp),%esi
  8025ff:	89 ec                	mov    %ebp,%esp
  802601:	5d                   	pop    %ebp
  802602:	c3                   	ret    
	...

00802610 <devpipe_stat>:
	return i;
}

static int
devpipe_stat(struct Fd *fd, struct Stat *stat)
{
  802610:	55                   	push   %ebp
  802611:	89 e5                	mov    %esp,%ebp
  802613:	83 ec 18             	sub    $0x18,%esp
  802616:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  802619:	89 75 fc             	mov    %esi,-0x4(%ebp)
  80261c:	8b 75 0c             	mov    0xc(%ebp),%esi
	struct Pipe *p = (struct Pipe*) fd2data(fd);
  80261f:	8b 45 08             	mov    0x8(%ebp),%eax
  802622:	89 04 24             	mov    %eax,(%esp)
  802625:	e8 c6 eb ff ff       	call   8011f0 <fd2data>
  80262a:	89 c3                	mov    %eax,%ebx
	strcpy(stat->st_name, "<pipe>");
  80262c:	c7 44 24 04 2b 35 80 	movl   $0x80352b,0x4(%esp)
  802633:	00 
  802634:	89 34 24             	mov    %esi,(%esp)
  802637:	e8 1e e3 ff ff       	call   80095a <strcpy>
	stat->st_size = p->p_wpos - p->p_rpos;
  80263c:	8b 43 04             	mov    0x4(%ebx),%eax
  80263f:	2b 03                	sub    (%ebx),%eax
  802641:	89 86 80 00 00 00    	mov    %eax,0x80(%esi)
	stat->st_isdir = 0;
  802647:	c7 86 84 00 00 00 00 	movl   $0x0,0x84(%esi)
  80264e:	00 00 00 
	stat->st_dev = &devpipe;
  802651:	c7 86 88 00 00 00 3c 	movl   $0x80703c,0x88(%esi)
  802658:	70 80 00 
	return 0;
}
  80265b:	b8 00 00 00 00       	mov    $0x0,%eax
  802660:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  802663:	8b 75 fc             	mov    -0x4(%ebp),%esi
  802666:	89 ec                	mov    %ebp,%esp
  802668:	5d                   	pop    %ebp
  802669:	c3                   	ret    

0080266a <devpipe_close>:

static int
devpipe_close(struct Fd *fd)
{
  80266a:	55                   	push   %ebp
  80266b:	89 e5                	mov    %esp,%ebp
  80266d:	53                   	push   %ebx
  80266e:	83 ec 14             	sub    $0x14,%esp
  802671:	8b 5d 08             	mov    0x8(%ebp),%ebx
	(void) sys_page_unmap(0, fd);
  802674:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  802678:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80267f:	e8 76 e9 ff ff       	call   800ffa <sys_page_unmap>
	return sys_page_unmap(0, fd2data(fd));
  802684:	89 1c 24             	mov    %ebx,(%esp)
  802687:	e8 64 eb ff ff       	call   8011f0 <fd2data>
  80268c:	89 44 24 04          	mov    %eax,0x4(%esp)
  802690:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802697:	e8 5e e9 ff ff       	call   800ffa <sys_page_unmap>
}
  80269c:	83 c4 14             	add    $0x14,%esp
  80269f:	5b                   	pop    %ebx
  8026a0:	5d                   	pop    %ebp
  8026a1:	c3                   	ret    

008026a2 <_pipeisclosed>:
	return r;
}

static int
_pipeisclosed(struct Fd *fd, struct Pipe *p)
{
  8026a2:	55                   	push   %ebp
  8026a3:	89 e5                	mov    %esp,%ebp
  8026a5:	57                   	push   %edi
  8026a6:	56                   	push   %esi
  8026a7:	53                   	push   %ebx
  8026a8:	83 ec 2c             	sub    $0x2c,%esp
  8026ab:	89 c7                	mov    %eax,%edi
  8026ad:	89 55 e4             	mov    %edx,-0x1c(%ebp)
	int n, nn, ret;

	while (1) {
		n = env->env_runs;
  8026b0:	a1 74 70 80 00       	mov    0x807074,%eax
  8026b5:	8b 58 58             	mov    0x58(%eax),%ebx
		ret = pageref(fd) == pageref(p);
  8026b8:	89 3c 24             	mov    %edi,(%esp)
  8026bb:	e8 b4 05 00 00       	call   802c74 <pageref>
  8026c0:	89 c6                	mov    %eax,%esi
  8026c2:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8026c5:	89 04 24             	mov    %eax,(%esp)
  8026c8:	e8 a7 05 00 00       	call   802c74 <pageref>
  8026cd:	39 c6                	cmp    %eax,%esi
  8026cf:	0f 94 c0             	sete   %al
  8026d2:	0f b6 c0             	movzbl %al,%eax
		nn = env->env_runs;
  8026d5:	8b 15 74 70 80 00    	mov    0x807074,%edx
  8026db:	8b 4a 58             	mov    0x58(%edx),%ecx
		if (n == nn)
  8026de:	39 cb                	cmp    %ecx,%ebx
  8026e0:	75 08                	jne    8026ea <_pipeisclosed+0x48>
			return ret;
		if (n != nn && ret == 1)
			cprintf("pipe race avoided\n", n, env->env_runs, ret);
	}
}
  8026e2:	83 c4 2c             	add    $0x2c,%esp
  8026e5:	5b                   	pop    %ebx
  8026e6:	5e                   	pop    %esi
  8026e7:	5f                   	pop    %edi
  8026e8:	5d                   	pop    %ebp
  8026e9:	c3                   	ret    
		n = env->env_runs;
		ret = pageref(fd) == pageref(p);
		nn = env->env_runs;
		if (n == nn)
			return ret;
		if (n != nn && ret == 1)
  8026ea:	83 f8 01             	cmp    $0x1,%eax
  8026ed:	75 c1                	jne    8026b0 <_pipeisclosed+0xe>
			cprintf("pipe race avoided\n", n, env->env_runs, ret);
  8026ef:	8b 52 58             	mov    0x58(%edx),%edx
  8026f2:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8026f6:	89 54 24 08          	mov    %edx,0x8(%esp)
  8026fa:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8026fe:	c7 04 24 32 35 80 00 	movl   $0x803532,(%esp)
  802705:	e8 83 db ff ff       	call   80028d <cprintf>
  80270a:	eb a4                	jmp    8026b0 <_pipeisclosed+0xe>

0080270c <devpipe_write>:
	return i;
}

static ssize_t
devpipe_write(struct Fd *fd, const void *vbuf, size_t n)
{
  80270c:	55                   	push   %ebp
  80270d:	89 e5                	mov    %esp,%ebp
  80270f:	57                   	push   %edi
  802710:	56                   	push   %esi
  802711:	53                   	push   %ebx
  802712:	83 ec 1c             	sub    $0x1c,%esp
  802715:	8b 75 08             	mov    0x8(%ebp),%esi
	const uint8_t *buf;
	size_t i;
	struct Pipe *p;

	p = (struct Pipe*) fd2data(fd);
  802718:	89 34 24             	mov    %esi,(%esp)
  80271b:	e8 d0 ea ff ff       	call   8011f0 <fd2data>
  802720:	89 c3                	mov    %eax,%ebx
	if (debug)
		cprintf("[%08x] devpipe_write %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  802722:	bf 00 00 00 00       	mov    $0x0,%edi
  802727:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  80272b:	75 54                	jne    802781 <devpipe_write+0x75>
  80272d:	eb 60                	jmp    80278f <devpipe_write+0x83>
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
			// pipe is full
			// if all the readers are gone
			// (it's only writers like us now),
			// note eof
			if (_pipeisclosed(fd, p))
  80272f:	89 da                	mov    %ebx,%edx
  802731:	89 f0                	mov    %esi,%eax
  802733:	e8 6a ff ff ff       	call   8026a2 <_pipeisclosed>
  802738:	85 c0                	test   %eax,%eax
  80273a:	74 07                	je     802743 <devpipe_write+0x37>
  80273c:	b8 00 00 00 00       	mov    $0x0,%eax
  802741:	eb 53                	jmp    802796 <devpipe_write+0x8a>
				return 0;
			// yield and see what happens
			if (debug)
				cprintf("devpipe_write yield\n");
			sys_yield();
  802743:	90                   	nop
  802744:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802748:	e8 c8 e9 ff ff       	call   801115 <sys_yield>
		cprintf("[%08x] devpipe_write %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
  80274d:	8b 43 04             	mov    0x4(%ebx),%eax
  802750:	8b 13                	mov    (%ebx),%edx
  802752:	83 c2 20             	add    $0x20,%edx
  802755:	39 d0                	cmp    %edx,%eax
  802757:	73 d6                	jae    80272f <devpipe_write+0x23>
				cprintf("devpipe_write yield\n");
			sys_yield();
		}
		// there's room for a byte.  store it.
		// wait to increment wpos until the byte is stored!
		p->p_buf[p->p_wpos % PIPEBUFSIZ] = buf[i];
  802759:	89 c2                	mov    %eax,%edx
  80275b:	c1 fa 1f             	sar    $0x1f,%edx
  80275e:	c1 ea 1b             	shr    $0x1b,%edx
  802761:	01 d0                	add    %edx,%eax
  802763:	83 e0 1f             	and    $0x1f,%eax
  802766:	29 d0                	sub    %edx,%eax
  802768:	89 c2                	mov    %eax,%edx
  80276a:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  80276d:	0f b6 04 39          	movzbl (%ecx,%edi,1),%eax
  802771:	88 44 13 08          	mov    %al,0x8(%ebx,%edx,1)
		p->p_wpos++;
  802775:	83 43 04 01          	addl   $0x1,0x4(%ebx)
	if (debug)
		cprintf("[%08x] devpipe_write %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  802779:	83 c7 01             	add    $0x1,%edi
  80277c:	39 7d 10             	cmp    %edi,0x10(%ebp)
  80277f:	76 13                	jbe    802794 <devpipe_write+0x88>
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
  802781:	8b 43 04             	mov    0x4(%ebx),%eax
  802784:	8b 13                	mov    (%ebx),%edx
  802786:	83 c2 20             	add    $0x20,%edx
  802789:	39 d0                	cmp    %edx,%eax
  80278b:	73 a2                	jae    80272f <devpipe_write+0x23>
  80278d:	eb ca                	jmp    802759 <devpipe_write+0x4d>
  80278f:	bf 00 00 00 00       	mov    $0x0,%edi
		// wait to increment wpos until the byte is stored!
		p->p_buf[p->p_wpos % PIPEBUFSIZ] = buf[i];
		p->p_wpos++;
	}
	
	return i;
  802794:	89 f8                	mov    %edi,%eax
}
  802796:	83 c4 1c             	add    $0x1c,%esp
  802799:	5b                   	pop    %ebx
  80279a:	5e                   	pop    %esi
  80279b:	5f                   	pop    %edi
  80279c:	5d                   	pop    %ebp
  80279d:	c3                   	ret    

0080279e <devpipe_read>:
	return _pipeisclosed(fd, p);
}

static ssize_t
devpipe_read(struct Fd *fd, void *vbuf, size_t n)
{
  80279e:	55                   	push   %ebp
  80279f:	89 e5                	mov    %esp,%ebp
  8027a1:	83 ec 28             	sub    $0x28,%esp
  8027a4:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8027a7:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8027aa:	89 7d fc             	mov    %edi,-0x4(%ebp)
  8027ad:	8b 7d 08             	mov    0x8(%ebp),%edi
	uint8_t *buf;
	size_t i;
	struct Pipe *p;

	p = (struct Pipe*)fd2data(fd);
  8027b0:	89 3c 24             	mov    %edi,(%esp)
  8027b3:	e8 38 ea ff ff       	call   8011f0 <fd2data>
  8027b8:	89 c3                	mov    %eax,%ebx
	if (debug)
		cprintf("[%08x] devpipe_read %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  8027ba:	be 00 00 00 00       	mov    $0x0,%esi
  8027bf:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  8027c3:	75 4c                	jne    802811 <devpipe_read+0x73>
  8027c5:	eb 5b                	jmp    802822 <devpipe_read+0x84>
		while (p->p_rpos == p->p_wpos) {
			// pipe is empty
			// if we got any data, return it
			if (i > 0)
				return i;
  8027c7:	89 f0                	mov    %esi,%eax
  8027c9:	eb 5e                	jmp    802829 <devpipe_read+0x8b>
			// if all the writers are gone, note eof
			if (_pipeisclosed(fd, p))
  8027cb:	89 da                	mov    %ebx,%edx
  8027cd:	89 f8                	mov    %edi,%eax
  8027cf:	90                   	nop
  8027d0:	e8 cd fe ff ff       	call   8026a2 <_pipeisclosed>
  8027d5:	85 c0                	test   %eax,%eax
  8027d7:	74 07                	je     8027e0 <devpipe_read+0x42>
  8027d9:	b8 00 00 00 00       	mov    $0x0,%eax
  8027de:	eb 49                	jmp    802829 <devpipe_read+0x8b>
				return 0;
			// yield and see what happens
			if (debug)
				cprintf("devpipe_read yield\n");
			sys_yield();
  8027e0:	e8 30 e9 ff ff       	call   801115 <sys_yield>
		cprintf("[%08x] devpipe_read %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
		while (p->p_rpos == p->p_wpos) {
  8027e5:	8b 03                	mov    (%ebx),%eax
  8027e7:	3b 43 04             	cmp    0x4(%ebx),%eax
  8027ea:	74 df                	je     8027cb <devpipe_read+0x2d>
				cprintf("devpipe_read yield\n");
			sys_yield();
		}
		// there's a byte.  take it.
		// wait to increment rpos until the byte is taken!
		buf[i] = p->p_buf[p->p_rpos % PIPEBUFSIZ];
  8027ec:	89 c2                	mov    %eax,%edx
  8027ee:	c1 fa 1f             	sar    $0x1f,%edx
  8027f1:	c1 ea 1b             	shr    $0x1b,%edx
  8027f4:	01 d0                	add    %edx,%eax
  8027f6:	83 e0 1f             	and    $0x1f,%eax
  8027f9:	29 d0                	sub    %edx,%eax
  8027fb:	0f b6 44 03 08       	movzbl 0x8(%ebx,%eax,1),%eax
  802800:	8b 55 0c             	mov    0xc(%ebp),%edx
  802803:	88 04 32             	mov    %al,(%edx,%esi,1)
		p->p_rpos++;
  802806:	83 03 01             	addl   $0x1,(%ebx)
	if (debug)
		cprintf("[%08x] devpipe_read %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  802809:	83 c6 01             	add    $0x1,%esi
  80280c:	39 75 10             	cmp    %esi,0x10(%ebp)
  80280f:	76 16                	jbe    802827 <devpipe_read+0x89>
		while (p->p_rpos == p->p_wpos) {
  802811:	8b 03                	mov    (%ebx),%eax
  802813:	3b 43 04             	cmp    0x4(%ebx),%eax
  802816:	75 d4                	jne    8027ec <devpipe_read+0x4e>
			// pipe is empty
			// if we got any data, return it
			if (i > 0)
  802818:	85 f6                	test   %esi,%esi
  80281a:	75 ab                	jne    8027c7 <devpipe_read+0x29>
  80281c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802820:	eb a9                	jmp    8027cb <devpipe_read+0x2d>
  802822:	be 00 00 00 00       	mov    $0x0,%esi
		// there's a byte.  take it.
		// wait to increment rpos until the byte is taken!
		buf[i] = p->p_buf[p->p_rpos % PIPEBUFSIZ];
		p->p_rpos++;
	}
	return i;
  802827:	89 f0                	mov    %esi,%eax
}
  802829:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  80282c:	8b 75 f8             	mov    -0x8(%ebp),%esi
  80282f:	8b 7d fc             	mov    -0x4(%ebp),%edi
  802832:	89 ec                	mov    %ebp,%esp
  802834:	5d                   	pop    %ebp
  802835:	c3                   	ret    

00802836 <pipeisclosed>:
	}
}

int
pipeisclosed(int fdnum)
{
  802836:	55                   	push   %ebp
  802837:	89 e5                	mov    %esp,%ebp
  802839:	83 ec 28             	sub    $0x28,%esp
	struct Fd *fd;
	struct Pipe *p;
	int r;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  80283c:	8d 45 f4             	lea    -0xc(%ebp),%eax
  80283f:	89 44 24 04          	mov    %eax,0x4(%esp)
  802843:	8b 45 08             	mov    0x8(%ebp),%eax
  802846:	89 04 24             	mov    %eax,(%esp)
  802849:	e8 2f ea ff ff       	call   80127d <fd_lookup>
  80284e:	85 c0                	test   %eax,%eax
  802850:	78 15                	js     802867 <pipeisclosed+0x31>
		return r;
	p = (struct Pipe*) fd2data(fd);
  802852:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802855:	89 04 24             	mov    %eax,(%esp)
  802858:	e8 93 e9 ff ff       	call   8011f0 <fd2data>
	return _pipeisclosed(fd, p);
  80285d:	89 c2                	mov    %eax,%edx
  80285f:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802862:	e8 3b fe ff ff       	call   8026a2 <_pipeisclosed>
}
  802867:	c9                   	leave  
  802868:	c3                   	ret    

00802869 <pipe>:
	uint8_t p_buf[PIPEBUFSIZ];	// data buffer
};

int
pipe(int pfd[2])
{
  802869:	55                   	push   %ebp
  80286a:	89 e5                	mov    %esp,%ebp
  80286c:	83 ec 48             	sub    $0x48,%esp
  80286f:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  802872:	89 75 f8             	mov    %esi,-0x8(%ebp)
  802875:	89 7d fc             	mov    %edi,-0x4(%ebp)
  802878:	8b 7d 08             	mov    0x8(%ebp),%edi
	int r;
	struct Fd *fd0, *fd1;
	void *va;

	// allocate the file descriptor table entries
	if ((r = fd_alloc(&fd0)) < 0
  80287b:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  80287e:	89 04 24             	mov    %eax,(%esp)
  802881:	e8 85 e9 ff ff       	call   80120b <fd_alloc>
  802886:	89 c3                	mov    %eax,%ebx
  802888:	85 c0                	test   %eax,%eax
  80288a:	0f 88 42 01 00 00    	js     8029d2 <pipe+0x169>
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  802890:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  802897:	00 
  802898:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  80289b:	89 44 24 04          	mov    %eax,0x4(%esp)
  80289f:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8028a6:	e8 0b e8 ff ff       	call   8010b6 <sys_page_alloc>
  8028ab:	89 c3                	mov    %eax,%ebx
	int r;
	struct Fd *fd0, *fd1;
	void *va;

	// allocate the file descriptor table entries
	if ((r = fd_alloc(&fd0)) < 0
  8028ad:	85 c0                	test   %eax,%eax
  8028af:	0f 88 1d 01 00 00    	js     8029d2 <pipe+0x169>
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
		goto err;

	if ((r = fd_alloc(&fd1)) < 0
  8028b5:	8d 45 e0             	lea    -0x20(%ebp),%eax
  8028b8:	89 04 24             	mov    %eax,(%esp)
  8028bb:	e8 4b e9 ff ff       	call   80120b <fd_alloc>
  8028c0:	89 c3                	mov    %eax,%ebx
  8028c2:	85 c0                	test   %eax,%eax
  8028c4:	0f 88 f5 00 00 00    	js     8029bf <pipe+0x156>
	    || (r = sys_page_alloc(0, fd1, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  8028ca:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  8028d1:	00 
  8028d2:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8028d5:	89 44 24 04          	mov    %eax,0x4(%esp)
  8028d9:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8028e0:	e8 d1 e7 ff ff       	call   8010b6 <sys_page_alloc>
  8028e5:	89 c3                	mov    %eax,%ebx
	// allocate the file descriptor table entries
	if ((r = fd_alloc(&fd0)) < 0
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
		goto err;

	if ((r = fd_alloc(&fd1)) < 0
  8028e7:	85 c0                	test   %eax,%eax
  8028e9:	0f 88 d0 00 00 00    	js     8029bf <pipe+0x156>
	    || (r = sys_page_alloc(0, fd1, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
		goto err1;

	// allocate the pipe structure as first data page in both
	va = fd2data(fd0);
  8028ef:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8028f2:	89 04 24             	mov    %eax,(%esp)
  8028f5:	e8 f6 e8 ff ff       	call   8011f0 <fd2data>
  8028fa:	89 c6                	mov    %eax,%esi
	if ((r = sys_page_alloc(0, va, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  8028fc:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  802903:	00 
  802904:	89 44 24 04          	mov    %eax,0x4(%esp)
  802908:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80290f:	e8 a2 e7 ff ff       	call   8010b6 <sys_page_alloc>
  802914:	89 c3                	mov    %eax,%ebx
  802916:	85 c0                	test   %eax,%eax
  802918:	0f 88 8e 00 00 00    	js     8029ac <pipe+0x143>
		goto err2;
	if ((r = sys_page_map(0, va, 0, fd2data(fd1), PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  80291e:	8b 45 e0             	mov    -0x20(%ebp),%eax
  802921:	89 04 24             	mov    %eax,(%esp)
  802924:	e8 c7 e8 ff ff       	call   8011f0 <fd2data>
  802929:	c7 44 24 10 07 04 00 	movl   $0x407,0x10(%esp)
  802930:	00 
  802931:	89 44 24 0c          	mov    %eax,0xc(%esp)
  802935:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  80293c:	00 
  80293d:	89 74 24 04          	mov    %esi,0x4(%esp)
  802941:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802948:	e8 0b e7 ff ff       	call   801058 <sys_page_map>
  80294d:	89 c3                	mov    %eax,%ebx
  80294f:	85 c0                	test   %eax,%eax
  802951:	78 49                	js     80299c <pipe+0x133>
		goto err3;

	// set up fd structures
	fd0->fd_dev_id = devpipe.dev_id;
  802953:	b8 3c 70 80 00       	mov    $0x80703c,%eax
  802958:	8b 08                	mov    (%eax),%ecx
  80295a:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  80295d:	89 0a                	mov    %ecx,(%edx)
	fd0->fd_omode = O_RDONLY;
  80295f:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  802962:	c7 42 08 00 00 00 00 	movl   $0x0,0x8(%edx)

	fd1->fd_dev_id = devpipe.dev_id;
  802969:	8b 10                	mov    (%eax),%edx
  80296b:	8b 45 e0             	mov    -0x20(%ebp),%eax
  80296e:	89 10                	mov    %edx,(%eax)
	fd1->fd_omode = O_WRONLY;
  802970:	8b 45 e0             	mov    -0x20(%ebp),%eax
  802973:	c7 40 08 01 00 00 00 	movl   $0x1,0x8(%eax)

	if (debug)
		cprintf("[%08x] pipecreate %08x\n", env->env_id, vpt[VPN(va)]);

	pfd[0] = fd2num(fd0);
  80297a:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  80297d:	89 04 24             	mov    %eax,(%esp)
  802980:	e8 5b e8 ff ff       	call   8011e0 <fd2num>
  802985:	89 07                	mov    %eax,(%edi)
	pfd[1] = fd2num(fd1);
  802987:	8b 45 e0             	mov    -0x20(%ebp),%eax
  80298a:	89 04 24             	mov    %eax,(%esp)
  80298d:	e8 4e e8 ff ff       	call   8011e0 <fd2num>
  802992:	89 47 04             	mov    %eax,0x4(%edi)
  802995:	bb 00 00 00 00       	mov    $0x0,%ebx
	return 0;
  80299a:	eb 36                	jmp    8029d2 <pipe+0x169>

    err3:
	sys_page_unmap(0, va);
  80299c:	89 74 24 04          	mov    %esi,0x4(%esp)
  8029a0:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8029a7:	e8 4e e6 ff ff       	call   800ffa <sys_page_unmap>
    err2:
	sys_page_unmap(0, fd1);
  8029ac:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8029af:	89 44 24 04          	mov    %eax,0x4(%esp)
  8029b3:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8029ba:	e8 3b e6 ff ff       	call   800ffa <sys_page_unmap>
    err1:
	sys_page_unmap(0, fd0);
  8029bf:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8029c2:	89 44 24 04          	mov    %eax,0x4(%esp)
  8029c6:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8029cd:	e8 28 e6 ff ff       	call   800ffa <sys_page_unmap>
    err:
	return r;
}
  8029d2:	89 d8                	mov    %ebx,%eax
  8029d4:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  8029d7:	8b 75 f8             	mov    -0x8(%ebp),%esi
  8029da:	8b 7d fc             	mov    -0x4(%ebp),%edi
  8029dd:	89 ec                	mov    %ebp,%esp
  8029df:	5d                   	pop    %ebp
  8029e0:	c3                   	ret    
	...

008029f0 <devcons_close>:
	return tot;
}

static int
devcons_close(struct Fd *fd)
{
  8029f0:	55                   	push   %ebp
  8029f1:	89 e5                	mov    %esp,%ebp
	USED(fd);

	return 0;
}
  8029f3:	b8 00 00 00 00       	mov    $0x0,%eax
  8029f8:	5d                   	pop    %ebp
  8029f9:	c3                   	ret    

008029fa <devcons_stat>:

static int
devcons_stat(struct Fd *fd, struct Stat *stat)
{
  8029fa:	55                   	push   %ebp
  8029fb:	89 e5                	mov    %esp,%ebp
  8029fd:	83 ec 18             	sub    $0x18,%esp
	strcpy(stat->st_name, "<cons>");
  802a00:	c7 44 24 04 4a 35 80 	movl   $0x80354a,0x4(%esp)
  802a07:	00 
  802a08:	8b 45 0c             	mov    0xc(%ebp),%eax
  802a0b:	89 04 24             	mov    %eax,(%esp)
  802a0e:	e8 47 df ff ff       	call   80095a <strcpy>
	return 0;
}
  802a13:	b8 00 00 00 00       	mov    $0x0,%eax
  802a18:	c9                   	leave  
  802a19:	c3                   	ret    

00802a1a <devcons_write>:
	return 1;
}

static ssize_t
devcons_write(struct Fd *fd, const void *vbuf, size_t n)
{
  802a1a:	55                   	push   %ebp
  802a1b:	89 e5                	mov    %esp,%ebp
  802a1d:	57                   	push   %edi
  802a1e:	56                   	push   %esi
  802a1f:	53                   	push   %ebx
  802a20:	81 ec 9c 00 00 00    	sub    $0x9c,%esp
	int tot, m;
	char buf[128];

	// mistake: have to nul-terminate arg to sys_cputs, 
	// so we have to copy vbuf into buf in chunks and nul-terminate.
	for (tot = 0; tot < n; tot += m) {
  802a26:	b8 00 00 00 00       	mov    $0x0,%eax
  802a2b:	be 00 00 00 00       	mov    $0x0,%esi
  802a30:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  802a34:	74 41                	je     802a77 <devcons_write+0x5d>
		m = n - tot;
		if (m > sizeof(buf) - 1)
			m = sizeof(buf) - 1;
		memmove(buf, (char*)vbuf + tot, m);
  802a36:	8d bd 68 ff ff ff    	lea    -0x98(%ebp),%edi
	char buf[128];

	// mistake: have to nul-terminate arg to sys_cputs, 
	// so we have to copy vbuf into buf in chunks and nul-terminate.
	for (tot = 0; tot < n; tot += m) {
		m = n - tot;
  802a3c:	8b 5d 10             	mov    0x10(%ebp),%ebx
  802a3f:	29 c3                	sub    %eax,%ebx
		if (m > sizeof(buf) - 1)
  802a41:	81 fb 80 00 00 00    	cmp    $0x80,%ebx
  802a47:	ba 7f 00 00 00       	mov    $0x7f,%edx
  802a4c:	0f 43 da             	cmovae %edx,%ebx
			m = sizeof(buf) - 1;
		memmove(buf, (char*)vbuf + tot, m);
  802a4f:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  802a53:	03 45 0c             	add    0xc(%ebp),%eax
  802a56:	89 44 24 04          	mov    %eax,0x4(%esp)
  802a5a:	89 3c 24             	mov    %edi,(%esp)
  802a5d:	e8 b3 e0 ff ff       	call   800b15 <memmove>
		sys_cputs(buf, m);
  802a62:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  802a66:	89 3c 24             	mov    %edi,(%esp)
  802a69:	e8 e2 e2 ff ff       	call   800d50 <sys_cputs>
	int tot, m;
	char buf[128];

	// mistake: have to nul-terminate arg to sys_cputs, 
	// so we have to copy vbuf into buf in chunks and nul-terminate.
	for (tot = 0; tot < n; tot += m) {
  802a6e:	01 de                	add    %ebx,%esi
  802a70:	89 f0                	mov    %esi,%eax
  802a72:	3b 75 10             	cmp    0x10(%ebp),%esi
  802a75:	72 c5                	jb     802a3c <devcons_write+0x22>
			m = sizeof(buf) - 1;
		memmove(buf, (char*)vbuf + tot, m);
		sys_cputs(buf, m);
	}
	return tot;
}
  802a77:	89 f0                	mov    %esi,%eax
  802a79:	81 c4 9c 00 00 00    	add    $0x9c,%esp
  802a7f:	5b                   	pop    %ebx
  802a80:	5e                   	pop    %esi
  802a81:	5f                   	pop    %edi
  802a82:	5d                   	pop    %ebp
  802a83:	c3                   	ret    

00802a84 <cputchar>:
#include <inc/string.h>
#include <inc/lib.h>

void
cputchar(int ch)
{
  802a84:	55                   	push   %ebp
  802a85:	89 e5                	mov    %esp,%ebp
  802a87:	83 ec 28             	sub    $0x28,%esp
	char c = ch;
  802a8a:	8b 45 08             	mov    0x8(%ebp),%eax
  802a8d:	88 45 f7             	mov    %al,-0x9(%ebp)

	// Unlike standard Unix's putchar,
	// the cputchar function _always_ outputs to the system console.
	sys_cputs(&c, 1);
  802a90:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  802a97:	00 
  802a98:	8d 45 f7             	lea    -0x9(%ebp),%eax
  802a9b:	89 04 24             	mov    %eax,(%esp)
  802a9e:	e8 ad e2 ff ff       	call   800d50 <sys_cputs>
}
  802aa3:	c9                   	leave  
  802aa4:	c3                   	ret    

00802aa5 <devcons_read>:
	return fd2num(fd);
}

static ssize_t
devcons_read(struct Fd *fd, void *vbuf, size_t n)
{
  802aa5:	55                   	push   %ebp
  802aa6:	89 e5                	mov    %esp,%ebp
  802aa8:	83 ec 08             	sub    $0x8,%esp
	int c;

	if (n == 0)
  802aab:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  802aaf:	75 07                	jne    802ab8 <devcons_read+0x13>
  802ab1:	eb 2d                	jmp    802ae0 <devcons_read+0x3b>
		return 0;
	while ((c = sys_cgetc()) == 0)
		sys_yield();
  802ab3:	e8 5d e6 ff ff       	call   801115 <sys_yield>
{
	int c;

	if (n == 0)
		return 0;
	while ((c = sys_cgetc()) == 0)
  802ab8:	90                   	nop
  802ab9:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  802ac0:	e8 57 e2 ff ff       	call   800d1c <sys_cgetc>
  802ac5:	85 c0                	test   %eax,%eax
  802ac7:	74 ea                	je     802ab3 <devcons_read+0xe>
  802ac9:	89 c2                	mov    %eax,%edx
		sys_yield();
	if (c < 0)
  802acb:	85 c0                	test   %eax,%eax
  802acd:	78 16                	js     802ae5 <devcons_read+0x40>
		return c;
	if (c == 0x04)	// ctl-d is eof
  802acf:	83 f8 04             	cmp    $0x4,%eax
  802ad2:	74 0c                	je     802ae0 <devcons_read+0x3b>
		return 0;
	*(char*)vbuf = c;
  802ad4:	8b 45 0c             	mov    0xc(%ebp),%eax
  802ad7:	88 10                	mov    %dl,(%eax)
  802ad9:	b8 01 00 00 00       	mov    $0x1,%eax
	return 1;
  802ade:	eb 05                	jmp    802ae5 <devcons_read+0x40>
  802ae0:	b8 00 00 00 00       	mov    $0x0,%eax
}
  802ae5:	c9                   	leave  
  802ae6:	c3                   	ret    

00802ae7 <opencons>:
	return fd->fd_dev_id == devcons.dev_id;
}

int
opencons(void)
{
  802ae7:	55                   	push   %ebp
  802ae8:	89 e5                	mov    %esp,%ebp
  802aea:	83 ec 28             	sub    $0x28,%esp
	int r;
	struct Fd* fd;

	if ((r = fd_alloc(&fd)) < 0)
  802aed:	8d 45 f4             	lea    -0xc(%ebp),%eax
  802af0:	89 04 24             	mov    %eax,(%esp)
  802af3:	e8 13 e7 ff ff       	call   80120b <fd_alloc>
  802af8:	85 c0                	test   %eax,%eax
  802afa:	78 3f                	js     802b3b <opencons+0x54>
		return r;
	if ((r = sys_page_alloc(0, fd, PTE_P|PTE_U|PTE_W|PTE_SHARE)) < 0)
  802afc:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  802b03:	00 
  802b04:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802b07:	89 44 24 04          	mov    %eax,0x4(%esp)
  802b0b:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802b12:	e8 9f e5 ff ff       	call   8010b6 <sys_page_alloc>
  802b17:	85 c0                	test   %eax,%eax
  802b19:	78 20                	js     802b3b <opencons+0x54>
		return r;
	fd->fd_dev_id = devcons.dev_id;
  802b1b:	8b 15 58 70 80 00    	mov    0x807058,%edx
  802b21:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802b24:	89 10                	mov    %edx,(%eax)
	fd->fd_omode = O_RDWR;
  802b26:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802b29:	c7 40 08 02 00 00 00 	movl   $0x2,0x8(%eax)
	return fd2num(fd);
  802b30:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802b33:	89 04 24             	mov    %eax,(%esp)
  802b36:	e8 a5 e6 ff ff       	call   8011e0 <fd2num>
}
  802b3b:	c9                   	leave  
  802b3c:	c3                   	ret    

00802b3d <iscons>:
	.dev_stat =	devcons_stat
};

int
iscons(int fdnum)
{
  802b3d:	55                   	push   %ebp
  802b3e:	89 e5                	mov    %esp,%ebp
  802b40:	83 ec 28             	sub    $0x28,%esp
	int r;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  802b43:	8d 45 f4             	lea    -0xc(%ebp),%eax
  802b46:	89 44 24 04          	mov    %eax,0x4(%esp)
  802b4a:	8b 45 08             	mov    0x8(%ebp),%eax
  802b4d:	89 04 24             	mov    %eax,(%esp)
  802b50:	e8 28 e7 ff ff       	call   80127d <fd_lookup>
  802b55:	85 c0                	test   %eax,%eax
  802b57:	78 11                	js     802b6a <iscons+0x2d>
		return r;
	return fd->fd_dev_id == devcons.dev_id;
  802b59:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802b5c:	8b 00                	mov    (%eax),%eax
  802b5e:	3b 05 58 70 80 00    	cmp    0x807058,%eax
  802b64:	0f 94 c0             	sete   %al
  802b67:	0f b6 c0             	movzbl %al,%eax
}
  802b6a:	c9                   	leave  
  802b6b:	c3                   	ret    

00802b6c <getchar>:
	sys_cputs(&c, 1);
}

int
getchar(void)
{
  802b6c:	55                   	push   %ebp
  802b6d:	89 e5                	mov    %esp,%ebp
  802b6f:	83 ec 28             	sub    $0x28,%esp
	int r;

	// JOS does, however, support standard _input_ redirection,
	// allowing the user to redirect script files to the shell and such.
	// getchar() reads a character from file descriptor 0.
	r = read(0, &c, 1);
  802b72:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
  802b79:	00 
  802b7a:	8d 45 f7             	lea    -0x9(%ebp),%eax
  802b7d:	89 44 24 04          	mov    %eax,0x4(%esp)
  802b81:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802b88:	e8 56 e9 ff ff       	call   8014e3 <read>
	if (r < 0)
  802b8d:	85 c0                	test   %eax,%eax
  802b8f:	78 0f                	js     802ba0 <getchar+0x34>
		return r;
	if (r < 1)
  802b91:	85 c0                	test   %eax,%eax
  802b93:	7f 07                	jg     802b9c <getchar+0x30>
  802b95:	b8 f8 ff ff ff       	mov    $0xfffffff8,%eax
  802b9a:	eb 04                	jmp    802ba0 <getchar+0x34>
		return -E_EOF;
	return c;
  802b9c:	0f b6 45 f7          	movzbl -0x9(%ebp),%eax
}
  802ba0:	c9                   	leave  
  802ba1:	c3                   	ret    
	...

00802bb0 <ipc_send>:
//   Use sys_yield() to be CPU-friendly.
//   If 'pg' is null, pass sys_ipc_recv a value that it will understand
//   as meaning "no page".  (Zero is not the right value.)
void
ipc_send(envid_t to_env, uint32_t val, void *pg, int perm)
{
  802bb0:	55                   	push   %ebp
  802bb1:	89 e5                	mov    %esp,%ebp
  802bb3:	57                   	push   %edi
  802bb4:	56                   	push   %esi
  802bb5:	53                   	push   %ebx
  802bb6:	83 ec 2c             	sub    $0x2c,%esp
  802bb9:	8b 75 08             	mov    0x8(%ebp),%esi
  802bbc:	8b 7d 0c             	mov    0xc(%ebp),%edi
  802bbf:	8b 5d 10             	mov    0x10(%ebp),%ebx
  int r   = 0;
  while (1) {
    if ((r=sys_ipc_try_send(to_env, val, (pg==NULL?(void *)UTOP:pg), perm)) == -E_IPC_NOT_RECV)
  802bc2:	85 db                	test   %ebx,%ebx
  802bc4:	b8 00 00 c0 ee       	mov    $0xeec00000,%eax
  802bc9:	0f 45 c3             	cmovne %ebx,%eax
  802bcc:	8b 55 14             	mov    0x14(%ebp),%edx
  802bcf:	89 54 24 0c          	mov    %edx,0xc(%esp)
  802bd3:	89 44 24 08          	mov    %eax,0x8(%esp)
  802bd7:	89 7c 24 04          	mov    %edi,0x4(%esp)
  802bdb:	89 34 24             	mov    %esi,(%esp)
  802bde:	e8 9d e2 ff ff       	call   800e80 <sys_ipc_try_send>
  802be3:	83 f8 f9             	cmp    $0xfffffff9,%eax
  802be6:	75 0a                	jne    802bf2 <ipc_send+0x42>
      sys_yield();
  802be8:	e8 28 e5 ff ff       	call   801115 <sys_yield>
    else if (r < 0)
      panic("ipc_send to [%x] failed. Error: %x\n", to_env, r);
    else
      return;
  }
  802bed:	8d 76 00             	lea    0x0(%esi),%esi
  802bf0:	eb d0                	jmp    802bc2 <ipc_send+0x12>
{
  int r   = 0;
  while (1) {
    if ((r=sys_ipc_try_send(to_env, val, (pg==NULL?(void *)UTOP:pg), perm)) == -E_IPC_NOT_RECV)
      sys_yield();
    else if (r < 0)
  802bf2:	85 c0                	test   %eax,%eax
  802bf4:	79 24                	jns    802c1a <ipc_send+0x6a>
      panic("ipc_send to [%x] failed. Error: %x\n", to_env, r);
  802bf6:	89 44 24 10          	mov    %eax,0x10(%esp)
  802bfa:	89 74 24 0c          	mov    %esi,0xc(%esp)
  802bfe:	c7 44 24 08 58 35 80 	movl   $0x803558,0x8(%esp)
  802c05:	00 
  802c06:	c7 44 24 04 36 00 00 	movl   $0x36,0x4(%esp)
  802c0d:	00 
  802c0e:	c7 04 24 7c 35 80 00 	movl   $0x80357c,(%esp)
  802c15:	e8 ae d5 ff ff       	call   8001c8 <_panic>
    else
      return;
  }
}
  802c1a:	83 c4 2c             	add    $0x2c,%esp
  802c1d:	5b                   	pop    %ebx
  802c1e:	5e                   	pop    %esi
  802c1f:	5f                   	pop    %edi
  802c20:	5d                   	pop    %ebp
  802c21:	c3                   	ret    

00802c22 <ipc_recv>:
//   If 'pg' is null, pass sys_ipc_recv a value that it will understand
//   as meaning "no page".  (Zero is not the right value, since that's
//   a perfectly valid place to map a page.)
int32_t
ipc_recv(envid_t *from_env_store, void *pg, int *perm_store)
{
  802c22:	55                   	push   %ebp
  802c23:	89 e5                	mov    %esp,%ebp
  802c25:	56                   	push   %esi
  802c26:	53                   	push   %ebx
  802c27:	83 ec 10             	sub    $0x10,%esp
  802c2a:	8b 5d 08             	mov    0x8(%ebp),%ebx
  802c2d:	8b 45 0c             	mov    0xc(%ebp),%eax
  802c30:	8b 75 10             	mov    0x10(%ebp),%esi
  int r;
  if ((r=sys_ipc_recv((pg==NULL?(void *)UTOP:pg)))<0)
  802c33:	85 c0                	test   %eax,%eax
  802c35:	ba 00 00 c0 ee       	mov    $0xeec00000,%edx
  802c3a:	0f 44 c2             	cmove  %edx,%eax
  802c3d:	89 04 24             	mov    %eax,(%esp)
  802c40:	e8 de e1 ff ff       	call   800e23 <sys_ipc_recv>
  802c45:	85 c0                	test   %eax,%eax
  802c47:	78 24                	js     802c6d <ipc_recv+0x4b>
    return r;

  if (from_env_store)
  802c49:	85 db                	test   %ebx,%ebx
  802c4b:	74 0a                	je     802c57 <ipc_recv+0x35>
    *from_env_store = env->env_ipc_from;
  802c4d:	a1 74 70 80 00       	mov    0x807074,%eax
  802c52:	8b 40 74             	mov    0x74(%eax),%eax
  802c55:	89 03                	mov    %eax,(%ebx)

  if (perm_store)
  802c57:	85 f6                	test   %esi,%esi
  802c59:	74 0a                	je     802c65 <ipc_recv+0x43>
    *perm_store     = env->env_ipc_perm;
  802c5b:	a1 74 70 80 00       	mov    0x807074,%eax
  802c60:	8b 40 78             	mov    0x78(%eax),%eax
  802c63:	89 06                	mov    %eax,(%esi)

  return env->env_ipc_value;
  802c65:	a1 74 70 80 00       	mov    0x807074,%eax
  802c6a:	8b 40 70             	mov    0x70(%eax),%eax
}
  802c6d:	83 c4 10             	add    $0x10,%esp
  802c70:	5b                   	pop    %ebx
  802c71:	5e                   	pop    %esi
  802c72:	5d                   	pop    %ebp
  802c73:	c3                   	ret    

00802c74 <pageref>:
#include <inc/lib.h>

int
pageref(void *v)
{
  802c74:	55                   	push   %ebp
  802c75:	89 e5                	mov    %esp,%ebp
	pte_t pte;

	if (!(vpd[PDX(v)] & PTE_P))
  802c77:	8b 45 08             	mov    0x8(%ebp),%eax
  802c7a:	89 c2                	mov    %eax,%edx
  802c7c:	c1 ea 16             	shr    $0x16,%edx
  802c7f:	8b 14 95 00 d0 7b ef 	mov    -0x10843000(,%edx,4),%edx
  802c86:	f6 c2 01             	test   $0x1,%dl
  802c89:	74 26                	je     802cb1 <pageref+0x3d>
		return 0;
	pte = vpt[VPN(v)];
  802c8b:	c1 e8 0c             	shr    $0xc,%eax
  802c8e:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
	if (!(pte & PTE_P))
  802c95:	a8 01                	test   $0x1,%al
  802c97:	74 18                	je     802cb1 <pageref+0x3d>
		return 0;
	return pages[PPN(pte)].pp_ref;
  802c99:	c1 e8 0c             	shr    $0xc,%eax
  802c9c:	8d 14 40             	lea    (%eax,%eax,2),%edx
  802c9f:	c1 e2 02             	shl    $0x2,%edx
  802ca2:	b8 00 00 00 ef       	mov    $0xef000000,%eax
  802ca7:	0f b7 44 02 08       	movzwl 0x8(%edx,%eax,1),%eax
  802cac:	0f b7 c0             	movzwl %ax,%eax
  802caf:	eb 05                	jmp    802cb6 <pageref+0x42>
  802cb1:	b8 00 00 00 00       	mov    $0x0,%eax
}
  802cb6:	5d                   	pop    %ebp
  802cb7:	c3                   	ret    
	...

00802cc0 <__udivdi3>:
  802cc0:	55                   	push   %ebp
  802cc1:	89 e5                	mov    %esp,%ebp
  802cc3:	57                   	push   %edi
  802cc4:	56                   	push   %esi
  802cc5:	83 ec 10             	sub    $0x10,%esp
  802cc8:	8b 45 14             	mov    0x14(%ebp),%eax
  802ccb:	8b 55 08             	mov    0x8(%ebp),%edx
  802cce:	8b 75 10             	mov    0x10(%ebp),%esi
  802cd1:	8b 7d 0c             	mov    0xc(%ebp),%edi
  802cd4:	85 c0                	test   %eax,%eax
  802cd6:	89 55 f0             	mov    %edx,-0x10(%ebp)
  802cd9:	75 35                	jne    802d10 <__udivdi3+0x50>
  802cdb:	39 fe                	cmp    %edi,%esi
  802cdd:	77 61                	ja     802d40 <__udivdi3+0x80>
  802cdf:	85 f6                	test   %esi,%esi
  802ce1:	75 0b                	jne    802cee <__udivdi3+0x2e>
  802ce3:	b8 01 00 00 00       	mov    $0x1,%eax
  802ce8:	31 d2                	xor    %edx,%edx
  802cea:	f7 f6                	div    %esi
  802cec:	89 c6                	mov    %eax,%esi
  802cee:	8b 4d f0             	mov    -0x10(%ebp),%ecx
  802cf1:	31 d2                	xor    %edx,%edx
  802cf3:	89 f8                	mov    %edi,%eax
  802cf5:	f7 f6                	div    %esi
  802cf7:	89 c7                	mov    %eax,%edi
  802cf9:	89 c8                	mov    %ecx,%eax
  802cfb:	f7 f6                	div    %esi
  802cfd:	89 c1                	mov    %eax,%ecx
  802cff:	89 fa                	mov    %edi,%edx
  802d01:	89 c8                	mov    %ecx,%eax
  802d03:	83 c4 10             	add    $0x10,%esp
  802d06:	5e                   	pop    %esi
  802d07:	5f                   	pop    %edi
  802d08:	5d                   	pop    %ebp
  802d09:	c3                   	ret    
  802d0a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  802d10:	39 f8                	cmp    %edi,%eax
  802d12:	77 1c                	ja     802d30 <__udivdi3+0x70>
  802d14:	0f bd d0             	bsr    %eax,%edx
  802d17:	83 f2 1f             	xor    $0x1f,%edx
  802d1a:	89 55 f4             	mov    %edx,-0xc(%ebp)
  802d1d:	75 39                	jne    802d58 <__udivdi3+0x98>
  802d1f:	3b 75 f0             	cmp    -0x10(%ebp),%esi
  802d22:	0f 86 a0 00 00 00    	jbe    802dc8 <__udivdi3+0x108>
  802d28:	39 f8                	cmp    %edi,%eax
  802d2a:	0f 82 98 00 00 00    	jb     802dc8 <__udivdi3+0x108>
  802d30:	31 ff                	xor    %edi,%edi
  802d32:	31 c9                	xor    %ecx,%ecx
  802d34:	89 c8                	mov    %ecx,%eax
  802d36:	89 fa                	mov    %edi,%edx
  802d38:	83 c4 10             	add    $0x10,%esp
  802d3b:	5e                   	pop    %esi
  802d3c:	5f                   	pop    %edi
  802d3d:	5d                   	pop    %ebp
  802d3e:	c3                   	ret    
  802d3f:	90                   	nop
  802d40:	89 d1                	mov    %edx,%ecx
  802d42:	89 fa                	mov    %edi,%edx
  802d44:	89 c8                	mov    %ecx,%eax
  802d46:	31 ff                	xor    %edi,%edi
  802d48:	f7 f6                	div    %esi
  802d4a:	89 c1                	mov    %eax,%ecx
  802d4c:	89 fa                	mov    %edi,%edx
  802d4e:	89 c8                	mov    %ecx,%eax
  802d50:	83 c4 10             	add    $0x10,%esp
  802d53:	5e                   	pop    %esi
  802d54:	5f                   	pop    %edi
  802d55:	5d                   	pop    %ebp
  802d56:	c3                   	ret    
  802d57:	90                   	nop
  802d58:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  802d5c:	89 f2                	mov    %esi,%edx
  802d5e:	d3 e0                	shl    %cl,%eax
  802d60:	89 45 ec             	mov    %eax,-0x14(%ebp)
  802d63:	b8 20 00 00 00       	mov    $0x20,%eax
  802d68:	2b 45 f4             	sub    -0xc(%ebp),%eax
  802d6b:	89 c1                	mov    %eax,%ecx
  802d6d:	d3 ea                	shr    %cl,%edx
  802d6f:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  802d73:	0b 55 ec             	or     -0x14(%ebp),%edx
  802d76:	d3 e6                	shl    %cl,%esi
  802d78:	89 c1                	mov    %eax,%ecx
  802d7a:	89 75 e8             	mov    %esi,-0x18(%ebp)
  802d7d:	89 fe                	mov    %edi,%esi
  802d7f:	d3 ee                	shr    %cl,%esi
  802d81:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  802d85:	89 55 ec             	mov    %edx,-0x14(%ebp)
  802d88:	8b 55 f0             	mov    -0x10(%ebp),%edx
  802d8b:	d3 e7                	shl    %cl,%edi
  802d8d:	89 c1                	mov    %eax,%ecx
  802d8f:	d3 ea                	shr    %cl,%edx
  802d91:	09 d7                	or     %edx,%edi
  802d93:	89 f2                	mov    %esi,%edx
  802d95:	89 f8                	mov    %edi,%eax
  802d97:	f7 75 ec             	divl   -0x14(%ebp)
  802d9a:	89 d6                	mov    %edx,%esi
  802d9c:	89 c7                	mov    %eax,%edi
  802d9e:	f7 65 e8             	mull   -0x18(%ebp)
  802da1:	39 d6                	cmp    %edx,%esi
  802da3:	89 55 ec             	mov    %edx,-0x14(%ebp)
  802da6:	72 30                	jb     802dd8 <__udivdi3+0x118>
  802da8:	8b 55 f0             	mov    -0x10(%ebp),%edx
  802dab:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  802daf:	d3 e2                	shl    %cl,%edx
  802db1:	39 c2                	cmp    %eax,%edx
  802db3:	73 05                	jae    802dba <__udivdi3+0xfa>
  802db5:	3b 75 ec             	cmp    -0x14(%ebp),%esi
  802db8:	74 1e                	je     802dd8 <__udivdi3+0x118>
  802dba:	89 f9                	mov    %edi,%ecx
  802dbc:	31 ff                	xor    %edi,%edi
  802dbe:	e9 71 ff ff ff       	jmp    802d34 <__udivdi3+0x74>
  802dc3:	90                   	nop
  802dc4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802dc8:	31 ff                	xor    %edi,%edi
  802dca:	b9 01 00 00 00       	mov    $0x1,%ecx
  802dcf:	e9 60 ff ff ff       	jmp    802d34 <__udivdi3+0x74>
  802dd4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802dd8:	8d 4f ff             	lea    -0x1(%edi),%ecx
  802ddb:	31 ff                	xor    %edi,%edi
  802ddd:	89 c8                	mov    %ecx,%eax
  802ddf:	89 fa                	mov    %edi,%edx
  802de1:	83 c4 10             	add    $0x10,%esp
  802de4:	5e                   	pop    %esi
  802de5:	5f                   	pop    %edi
  802de6:	5d                   	pop    %ebp
  802de7:	c3                   	ret    
	...

00802df0 <__umoddi3>:
  802df0:	55                   	push   %ebp
  802df1:	89 e5                	mov    %esp,%ebp
  802df3:	57                   	push   %edi
  802df4:	56                   	push   %esi
  802df5:	83 ec 20             	sub    $0x20,%esp
  802df8:	8b 55 14             	mov    0x14(%ebp),%edx
  802dfb:	8b 4d 08             	mov    0x8(%ebp),%ecx
  802dfe:	8b 7d 10             	mov    0x10(%ebp),%edi
  802e01:	8b 75 0c             	mov    0xc(%ebp),%esi
  802e04:	85 d2                	test   %edx,%edx
  802e06:	89 c8                	mov    %ecx,%eax
  802e08:	89 4d f4             	mov    %ecx,-0xc(%ebp)
  802e0b:	75 13                	jne    802e20 <__umoddi3+0x30>
  802e0d:	39 f7                	cmp    %esi,%edi
  802e0f:	76 3f                	jbe    802e50 <__umoddi3+0x60>
  802e11:	89 f2                	mov    %esi,%edx
  802e13:	f7 f7                	div    %edi
  802e15:	89 d0                	mov    %edx,%eax
  802e17:	31 d2                	xor    %edx,%edx
  802e19:	83 c4 20             	add    $0x20,%esp
  802e1c:	5e                   	pop    %esi
  802e1d:	5f                   	pop    %edi
  802e1e:	5d                   	pop    %ebp
  802e1f:	c3                   	ret    
  802e20:	39 f2                	cmp    %esi,%edx
  802e22:	77 4c                	ja     802e70 <__umoddi3+0x80>
  802e24:	0f bd ca             	bsr    %edx,%ecx
  802e27:	83 f1 1f             	xor    $0x1f,%ecx
  802e2a:	89 4d f0             	mov    %ecx,-0x10(%ebp)
  802e2d:	75 51                	jne    802e80 <__umoddi3+0x90>
  802e2f:	3b 7d f4             	cmp    -0xc(%ebp),%edi
  802e32:	0f 87 e0 00 00 00    	ja     802f18 <__umoddi3+0x128>
  802e38:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802e3b:	29 f8                	sub    %edi,%eax
  802e3d:	19 d6                	sbb    %edx,%esi
  802e3f:	89 45 f4             	mov    %eax,-0xc(%ebp)
  802e42:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802e45:	89 f2                	mov    %esi,%edx
  802e47:	83 c4 20             	add    $0x20,%esp
  802e4a:	5e                   	pop    %esi
  802e4b:	5f                   	pop    %edi
  802e4c:	5d                   	pop    %ebp
  802e4d:	c3                   	ret    
  802e4e:	66 90                	xchg   %ax,%ax
  802e50:	85 ff                	test   %edi,%edi
  802e52:	75 0b                	jne    802e5f <__umoddi3+0x6f>
  802e54:	b8 01 00 00 00       	mov    $0x1,%eax
  802e59:	31 d2                	xor    %edx,%edx
  802e5b:	f7 f7                	div    %edi
  802e5d:	89 c7                	mov    %eax,%edi
  802e5f:	89 f0                	mov    %esi,%eax
  802e61:	31 d2                	xor    %edx,%edx
  802e63:	f7 f7                	div    %edi
  802e65:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802e68:	f7 f7                	div    %edi
  802e6a:	eb a9                	jmp    802e15 <__umoddi3+0x25>
  802e6c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802e70:	89 c8                	mov    %ecx,%eax
  802e72:	89 f2                	mov    %esi,%edx
  802e74:	83 c4 20             	add    $0x20,%esp
  802e77:	5e                   	pop    %esi
  802e78:	5f                   	pop    %edi
  802e79:	5d                   	pop    %ebp
  802e7a:	c3                   	ret    
  802e7b:	90                   	nop
  802e7c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802e80:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802e84:	d3 e2                	shl    %cl,%edx
  802e86:	89 55 f4             	mov    %edx,-0xc(%ebp)
  802e89:	ba 20 00 00 00       	mov    $0x20,%edx
  802e8e:	2b 55 f0             	sub    -0x10(%ebp),%edx
  802e91:	89 55 ec             	mov    %edx,-0x14(%ebp)
  802e94:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  802e98:	89 fa                	mov    %edi,%edx
  802e9a:	d3 ea                	shr    %cl,%edx
  802e9c:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802ea0:	0b 55 f4             	or     -0xc(%ebp),%edx
  802ea3:	d3 e7                	shl    %cl,%edi
  802ea5:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  802ea9:	89 55 f4             	mov    %edx,-0xc(%ebp)
  802eac:	89 f2                	mov    %esi,%edx
  802eae:	89 7d e8             	mov    %edi,-0x18(%ebp)
  802eb1:	89 c7                	mov    %eax,%edi
  802eb3:	d3 ea                	shr    %cl,%edx
  802eb5:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802eb9:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  802ebc:	89 c2                	mov    %eax,%edx
  802ebe:	d3 e6                	shl    %cl,%esi
  802ec0:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  802ec4:	d3 ea                	shr    %cl,%edx
  802ec6:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802eca:	09 d6                	or     %edx,%esi
  802ecc:	89 f0                	mov    %esi,%eax
  802ece:	8b 75 e4             	mov    -0x1c(%ebp),%esi
  802ed1:	d3 e7                	shl    %cl,%edi
  802ed3:	89 f2                	mov    %esi,%edx
  802ed5:	f7 75 f4             	divl   -0xc(%ebp)
  802ed8:	89 d6                	mov    %edx,%esi
  802eda:	f7 65 e8             	mull   -0x18(%ebp)
  802edd:	39 d6                	cmp    %edx,%esi
  802edf:	72 2b                	jb     802f0c <__umoddi3+0x11c>
  802ee1:	39 c7                	cmp    %eax,%edi
  802ee3:	72 23                	jb     802f08 <__umoddi3+0x118>
  802ee5:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802ee9:	29 c7                	sub    %eax,%edi
  802eeb:	19 d6                	sbb    %edx,%esi
  802eed:	89 f0                	mov    %esi,%eax
  802eef:	89 f2                	mov    %esi,%edx
  802ef1:	d3 ef                	shr    %cl,%edi
  802ef3:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  802ef7:	d3 e0                	shl    %cl,%eax
  802ef9:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802efd:	09 f8                	or     %edi,%eax
  802eff:	d3 ea                	shr    %cl,%edx
  802f01:	83 c4 20             	add    $0x20,%esp
  802f04:	5e                   	pop    %esi
  802f05:	5f                   	pop    %edi
  802f06:	5d                   	pop    %ebp
  802f07:	c3                   	ret    
  802f08:	39 d6                	cmp    %edx,%esi
  802f0a:	75 d9                	jne    802ee5 <__umoddi3+0xf5>
  802f0c:	2b 45 e8             	sub    -0x18(%ebp),%eax
  802f0f:	1b 55 f4             	sbb    -0xc(%ebp),%edx
  802f12:	eb d1                	jmp    802ee5 <__umoddi3+0xf5>
  802f14:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802f18:	39 f2                	cmp    %esi,%edx
  802f1a:	0f 82 18 ff ff ff    	jb     802e38 <__umoddi3+0x48>
  802f20:	e9 1d ff ff ff       	jmp    802e42 <__umoddi3+0x52>
